Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 10:45
    Sporarum edited #9792
  • 08:57
    yikf commented #12504
  • 08:52
    lrytz closed #12504
  • 08:52
    lrytz commented #12504
  • 08:51
    yikf edited #12504
  • 08:46
    yikf opened #12504
  • 07:41

    lrytz on 2.13.x

    fix build (JDK 17 + bootstrappe… Merge pull request #9816 from S… (compare)

  • 07:41
    lrytz closed #9816
  • 04:35
    SethTisue synchronize #1512
  • 02:10
    SethTisue edited #1511
  • 02:10
    SethTisue edited #1512
  • 02:09
    SethTisue labeled #1512
  • 02:09
    SethTisue labeled #1511
  • 02:09
    SethTisue assigned #1512
  • 02:09
    SethTisue opened #1512
  • 02:08
    SethTisue opened #1511
  • 00:23
    SethTisue commented #9815
  • 00:23
    SethTisue review_requested #9816
  • 00:22
    SethTisue edited #9816
  • 00:21
    SethTisue edited #9816
Josh
@joshlemer
"x" can be assigned values, it can be read and assigned to other values, updated. It's a var
Pierre Marais
@Deeds67
@joshlemer Do you see recursion as mutation then as well?
Josh
@joshlemer
I'm not saying I have any answers or rules, just pointing out that purity maybe is less black and white than it seems?
PsyfireX
@PsyfireX
No, that's not what's happening.
"if you squint really hard 98 + 1 = 100"
Josh
@joshlemer
Unless there's like really a rule for why this is not to be breaking referential transparency
PsyfireX
@PsyfireX
^ that is an incorrect statement relying on ignoring logic/facts in favor of fuzzy logic
Josh
@joshlemer
@PsyfireX I'd like to hear why this is wrong if you wouldn't mind elaborating
PsyfireX
@PsyfireX
What is being mutated in your example?
Josh
@joshlemer
@amitprasad01_twitter I'm not familiar but if you pose specific questions maybe someone will know
@PsyfireX the binding of "x" to 1
Martijn Hoekstra
@martijnhoekstra
@joshlemer I see your exmple, but what you did was show that you can interpret an impure language in a pure interpreter. Just because you can use pure programming to write an interpreter to interpret an impure program doesn't make the interpreter impure.
PsyfireX
@PsyfireX
The binding is never mutated
Josh
@joshlemer
@PsyfireX I apologize, the second appearance of "x" should be "x" -> Constant(12345)
@martijnhoekstra I get that but I'm not sure where you draw the line between what is in our language and what is in the interpreted language
PsyfireX
@PsyfireX
I think you're trying to say that when the accumulator receives the same key twice, that's mutation?
Josh
@joshlemer
yes
PsyfireX
@PsyfireX
The problem with a statment like that is that ... it's not mutatation
Josh
@joshlemer
Looks quite a bit like mutation to me
PsyfireX
@PsyfireX
Would you consider this mutation?
Seq(3) ++ Seq(4)
Josh
@joshlemer
No not typically
I would say almost certainly no
Martijn Hoekstra
@martijnhoekstra
@joshlemer what's in our language is scala - creating a binding like val x = 12345. Your interpreted language is the language with the primitives defined asAssignmentTo, interpreted by the function in the fold -- only when you give AssignmentTothe meaning of being a program, then the mutability shows up.
PsyfireX
@PsyfireX
Would you consider this mutation (from your example)
acc + ((ident, newValue))
Martijn Hoekstra
@martijnhoekstra
but then it's also clear what the dividing line is -- the language of AssignmentTo
Amit Prasad
@amitprasad01_twitter
@joshlemer I'm not able to create the object of a class which is injected in my testing module
Josh
@joshlemer
@martijnhoekstra what makes AssignmentTo a language any more than Option or Either?
Fabio Labella
@SystemFw
@joshlemer your code is referentially transparent. Purity is defined as referential transparency, there's no ambiguity there
Matthew Pickering
@mpickering
I am wondering about the internal design of the scala compiler. Is it correct that each phase of the compiler is a function which takes a CompilationUnit as an argument? In this case, what does the typer phase do? Does it mutate this value and add typing information? Is there any static guarantee that certain phases initialise certain fields?
Fabio Labella
@SystemFw
Option or Either are also "languages" (effects)
also, and I feel like this is getting lost: mutation ≠ impurity
referentially transparent mutation is pure
by definition
your language is a Free monoid (a List) of commands, where each command describes assigning a value to something
it's perfectly referentially transparent (pure), because the definition that defines purity (replacing an expression by its bound value doesn't change behaviour), holds
Martijn Hoekstra
@martijnhoekstra
@mpickering scalac parses source code to syntax trees. In subsequent phases more information is added to those trees. The typer phase hangs types on the trees
it's all very Christmasy
Matthew Pickering
@mpickering
but it is all dynamically typed yes?
Fabio Labella
@SystemFw

I see your exmple, but what you did was show that you can interpret an impure language in a pure interpreter. Just because you can use pure programming to write an interpreter to interpret an impure program doesn't make the interpreter impure.

So, in the example, neither the language or the interpreter are impure, at all

Harrison Houghton
@hrhino
It's statically Trees. Most trees wind up with tpe (and symbol, if it makes sense) set after typer.
Some Tree subclasses don't show up before or after certain phases.
so it's pretty loosey-goosey like that.
Matthew Pickering
@mpickering
ok
Martijn Hoekstra
@martijnhoekstra
to the compiler, the types of your program are values, the types of your program are not types in the compiler
Matthew Pickering
@mpickering
@martijnhoekstra Yes but you can design a compiler so that the type of a typechecked AST is different to that of a parsed AST.
Harrison Houghton
@hrhino
Yes, ghc does that, for instance.
Martijn Hoekstra
@martijnhoekstra
it depends on who you mean by "you" -- if you mean me, then no :P
Harrison Houghton
@hrhino
Their tree is parameterized over the "name" type, which goes from RdrName (scalac's Name) to Name (a tuple of name/symbol/type) during typechecking.
Matthew Pickering
@mpickering
I was trying to understand how plugins could possibly work but now it makes sense
As I understand it though, the "parser" phase always has to come first because that takes a string as an argument rather than a CompilationUnit.