hi, (define my-snip-class
(new (class snip-class%
(super-new)
(send this set-classname "my-snip"))))
can you please elaborate in this context the use of set-classname
?
hi, (define my-snip-class
(new (class snip-class%
(super-new)
(send this set-classname "my-snip"))))
can you please explain why set-classname?
@sorawee yeah, that’s what i meant (although it might be clearer as a let loop)
Thank you to @samth, @sorawee, @kellysmith12.21 for teaching me a bit more about functional programming!
Now I just have to look up what values
are actually doing in the docs! Also didn’t know there were things like for/fold
and match-define
(or at least I only knew these vaguely and never found much use for them, or forgot to use them)
Also @sorawee what is PL?
programming languages (implementation / design / whatever)
“In PL, you can write a functional interpreter that supports mutable state by using what’s known as “store passing style”. This is similar, but instead of passing the store around, you pass the stream around.”
Right, it seemed like you were referring to some specific language here
Where PL is the language
Not specific language. I referred to how you can create a functional interpreter to interpret any language with mutation.
I see, thank you for clarifying. I suppose I am still a beginner at PL then :slightly_smiling_face:
I have used the awkwardness of a store-passing interpreter to motivate monads and do-notation.
Cool Wikipedia example though! This problem of preorder traversal seemed very hard, and took me hours to figure out that global file ports will help circumvent this problem, which made it seem sort of like a “hack”. Is store the same thing as stream then?
In Racket, I mean. the word “stream” seems to have a few different meanings in different languages, sort of
Never used do-notation in Racket, but I do know that it exists. Felt sort of weird to me at first because it seemed that imperative programming was seeping into functional programming. Would that help with this problem? Maybe a do-notation with some cons, car and cdr would help create the sort of “stack” we might need for this kind of problem
Gonna read into monads as well. Thanks @plragde. Not sure if this exists in #lang racket
however
Is there a way to write multi-line string literals in source code?
#<<EOF
hello
world
EOF
IIRC
you can change EOF to anything, as long as they match
Also IIRC, you can use @-expression, if you are OK with changing the reader @~a{
abc
def
}
Oh, actually:
"abc
def"
works already too. The benefit of the above two solutions is that you don’t need to escape quotes.
What would an immutable box be useful for?