Replies: 1 comment 9 replies
-
Ben:
I’m not objecting to this as a “this is the syntactic hill I shall die upon” level of fervor, but I don’t think I’m convinced the existing syntaxes lend themselves to this naming very cleanly, and am not sure if it’ll buy us more than it confuses. (I’m gonna guess that Emmanuel’s reaction will be something along the lines of “I’ve already worked through this in my lessons, and teaching more syntax takes away more time and cognitive budget from other things, so I don’t know if I’d actually use it in workshops.”) |
Beta Was this translation helpful? Give feedback.
-
Shriram:
We routinely see the pattern
in Pyret. Indeed, it's almost impossible to not write that: it's very rare to write a truly first-class table or reactor, especially early on.
I must admit that to me, these also look rather ugly, due to Pyret's indentation scheme (sorry BenL, but my Lisper eyes can never get used to Pyret indentation).
And yet we don't write
all the time. We think there's value to having named, first-order(-presenting) versions of what are actually anonymous, first-class values. In fact, at least some of our curricula go from
fun
tolam
in its generality, but I don't know of almost any situation where we would truly use the anonymous, first-class-ness of especially reactors, but even — because of their syntactic unwieldiness (size, indentation, etc.) even tables. In practice they're likely to almost always be named. Yet we've stuck students with the equivalent of onlylam
.Why can't we just name tables and reactors at the time of creation? There is not an obvious analog to
fun
/lam
(which anyway are not a "logical" pair, they're just historical precedent), and I'm not sure we want more new keywords floating about anyway. But what if you could write eitheror
Likewise
or
One could then even imagine allowing
[MIT Scheme actually had this construct. It's really useful when you want to define a lambda in the usual places you want a lambda, but suddenly realize you want it to be recursive. You don't have to refactor the code; you just name it and refer to that name recursively. It's not common but it's pretty handy when you want it. Yes, it's slightly ironic.]
One could imagine a consistent thing after the name (
is
is taken, but hypothetically, you always follow the name with the same keyword, likeis
), but I'm not sure that always parses well (the wayfrom
infor
doesn't always). Or just let each construct choose its own meaningful following keyword, or none at all — as above.Beta Was this translation helpful? Give feedback.
All reactions