fullmoon wrote:
I see how the two are different in that sense but they appear to function exactly the same to me.... So from my understanding, unevaluated arguments are basically a shortcut for wrapping certain inputs in "the block".
Ah, okay, I think I see why we're at cross purposes here. I totally agree with everything you said except for the word "shortcut." Grey borders are a shortcut for THE BLOCK, but the purpose -- the user interface purpose -- of unevaluated inputs isn't to be a shortcut, but rather to be a hiding mechanism.
Consider this: C-shaped slots are, as we now know from the BYOB experience, unevaluated inputs. (What's inside the C-slot is a script, but it doesn't look like a script -- at least, it doesn't look like a BYOB script-as-data in a grey border.) But if you can think back to when you first learned Scratch, I'll bet that that never occurred to you. It's not exactly that you thought they were evaluated; rather, you didn't really have evaluation as a concept in your head at all.
What you keep saying, correctly, is that from the computer's point of view an unevaluated input is no different from a procedure-type input. Then you take a misstep from pure computer science into user interface design by thinking, "since they mean the same they might as well look the same." That would be true if people were just computers, but actually people, especially ones who are just beginning at programming, build up mental models quite different from what's going on under the hood. This is a good thing! After all, what's really going on under the hood is a bunch of electrons whizzing around through remote-controlled switches (that's essentially what a transistor is when you're in the digital domain), and we don't want our beginners, or even our adult professional programmers, to have to think about that.
So, try to put yourself in the shoes of a beginner, who has no notion of "evaluation" in his/her head, and who is confronted with a block of the form
IF <condition> THEN <value> ELSE <value>
In this three-slot block, the last two slots have grey borders around them, while the first one doesn't. What do you make of this? Well, (a) something scary and complicated is going on, and (b) grey border means "non-Boolean," maybe? Or grey border means "maybe"? Or grey borders mean "mutually exclusive"? Anyway, not what we want people to think of when they see a grey border. And, by the way, if s/he is taught to think "function" about grey borders, then s/he will be confused by the fact that it's a function of no arguments -- not something you usually see in mathematics.
From a user interface standpoint, the situation is quite different when you see a grey border in, say, the MAP block. You're not going to make sense of MAP at all unless you already believe in functions as data. In the MAP block, the grey border is a welcome reminder that this one is the function input, as opposed to the list input.
Does that help?
Last edited by bharvey (2010-10-21 01:40:04)
Offline
fullmoon wrote:
This is more or less my third example, I just left out the "lambda" keyword because I don't think my parser needs it!
Oh! I misread that example because I got the parens and braces mixed up -- there are quite a lot of them. I thought the formal parameter was grouped with the each message rather than with the body, so it didn't look like a lambda to me. Now I get it.
Offline
fullmoon wrote:
I just left out the "lambda" keyword because I don't think my parser needs it! For clarity, though, I think I'll end up marking blocks/functions with a "@" symbol, because it doesn't seem to be getting much use anywhere else. I've also left out the colon-delimited arguments and I'm opting to go C-style, although we'll see what Jens can do to get me to change my mind
Hmm, syntax aside I like an explicit keyword like "lambda" better than a single character, especially one that's so overloaded with meaning like @, which I still read "at" as in Smalltalk's Points (x@y) or in e-mail addresses (name@domain). Since your C-syntax DSL somehow resembles JS How about using "function" as keyword?
Offline
@bharvey
I'm beginning to see what you mean when you say that unevaluated inputs are a hiding mechanism. After all, the primitive "repeat until" block takes an unevaluated boolean input, but you would never notice unless you were really thinking about it from another perspective! So keeping unevaluated inputs in the form they are now is really just another step in integrating BYOB with the way Scratch was designed.
@Jens
^ There's that "@" symbol again...perhaps I will rethink using it. But one of my least favorite things about Javascript is the function keyword -- it feels clumsy.
^ I'm also using "^" for "return".
Offline
fullmoon wrote:
After all, the primitive "repeat until" block takes an unevaluated boolean input, but you would never notice unless you were really thinking about it from another perspective!
Yes, precisely. For a while, before we invented unevaluated input types, we used grey hexagons for things like REPEAT UNTIL (as opposed to white hexagons for IF, which is happy to get an evaluated input that it uses once). Once we could think of the REPEAT UNTIL input as unevaluated-Boolean, rather than as Predicate type, we went back to white hexagons with a sigh of relief.
Offline
@Jens
Just had a Smalltalk epiphany moment. I was freaking out over the syntax for conditionals, when I realized I could actually create a method of the boolean type called ifTrue!
EDIT: I realize that this is pretty much completely off-topic, but I've chosen a syntax for blocks:
( say_hello_to = |name|{ ^"Hello, "+name } )
So the forEach example from earlier will look like this:
poemFragments forEach(|fragment|{ io out("One flew over "+fragment) })
Last edited by fullmoon (2010-10-21 16:04:37)
Offline
Wow, I love Smalltalk epiphanies like yours! Isn't it cool how you can build your own programming language out of lambdas and evaluating them? I also like your leaning towards Smalltalk syntax with the caret for return and the vertical bars for temporaries. Can't wait to try your new scripting language!
P.S. I voted for you
Offline
fullmoon wrote:
Code:
poemFragments forEach(|fragment|{ io out("One flew over "+fragment) })
Jens wrote:
I also like your leaning towards Smalltalk syntax with the caret for return and the vertical bars for temporaries.
Wait, he's using vertical bars for formal parameters; that's not what Smalltalk does, is it?
Offline
bharvey wrote:
fullmoon wrote:
Code:
poemFragments forEach(|fragment|{ io out("One flew over "+fragment) })Jens wrote:
I also like your leaning towards Smalltalk syntax with the caret for return and the vertical bars for temporaries.
Wait, he's using vertical bars for formal parameters; that's not what Smalltalk does, is it?
Well, in Smalltalk formal parameters for Blocks are indicated by a colon prefix each and separated from the Block's body by a single vertical bar, so there's one vertical bar in how this would look in Smalltalk:
poemFragments do: [ :eachFragment | Transcript cr; show: 'One flew over', eachFragment ]
or, if you wanted two formal parameters, you'd code something like this:
| print join firstNames lastNames | join := [ :firstString :secondString | firstString, ' ', secondString ]. print := [ :line | Transcript cr; show: line ]. firstNames := #(John Paul George Ringo). lastnames := #(Lennon McCartney Harrison Starr). firstNames sizeRepeat: [ :i | print value: (join value: (firstNames at: i) value: (lastNames at: i) ].
Last edited by Jens (2010-10-22 03:54:08)
Offline
Umm...wow. That is so complicated...(To me. XD) but yeah. I love BYOB!!!! It's just so...easy! Press make a block, set the types, program the block, that's it. A great mod of Scratch!
Offline
Jens wrote:
Well, in Smalltalk formal parameters for Blocks are indicated by a colon prefix each and separated from the Block's body by a single vertical bar, so there's one vertical bar in how this would look in Smalltalk:
Huh?
gotoX: x y: y self holdSubsprites. offset ifNotNil: [ offset _ offset + (x@y - self referencePosition) ]. self referencePosition: x@y. self releaseSubsprites.
Actual copy-pasted code. Two formal parameters. Zero vertical bars. Those things in your examples aren't formal parameters, Jens; they're script variables.
Offline
Guinea_Pig_Girl wrote:
Umm...wow. That is so complicated...(To me. XD) but yeah. I love BYOB!!!! It's just so...easy! Press make a block, set the types, program the block, that's it. A great mod of Scratch!
Thanks! That was the goal. Try out the tutorials and see if you learn to love the THE BLOCK block and the THE SCRIPT block.
A program like Scratch or BYOB that does so much, with such a fancy user interface, is going to be complicated "under the hood," but it's just a lot of details to keep track of, not magic.
Offline
bharvey wrote:
Jens wrote:
Well, in Smalltalk formal parameters for Blocks are indicated by a colon prefix each and separated from the Block's body by a single vertical bar, so there's one vertical bar in how this would look in Smalltalk:
Huh?
Code:
gotoX: x y: y self holdSubsprites. offset ifNotNil: [ offset _ offset + (x@y - self referencePosition) ]. self referencePosition: x@y. self releaseSubsprites.Actual copy-pasted code. Two formal parameters. Zero vertical bars. Those things in your examples aren't formal parameters, Jens; they're script variables.
I don't know nil about Smalltalk ( ) but to me that looks like a formal method definition rather than an anonymous block.
Offline
fullmoon wrote:
I don't know nil about Smalltalk ( ) but to me that looks like a formal method definition rather than an anonymous block.
Oh oops, the notation is different for lambdas? I see, it's supposed to remind you of the "such that" in set notation? I get it.
PS You know more about Smalltalk than I do! That's why it's all Jens's code.
EDIT: PPS: Congratulations!!! And demosthenes too!! Good thing this isn't like real-world elections, where the people I vote for always lose.
Last edited by bharvey (2010-10-22 12:25:58)
Offline
Another glitch:
Edit the type of any input in any block, and then go to Edit menu -> Undelete.
The internal script for the block is attached to the cursor.
Offline
rubiks_cube_guy238 wrote:
Another glitch:
Edit the type of any input in any block, and then go to Edit menu -> Undelete.
The internal script for the block is attached to the cursor.
How do you guys think to try these things???
Thanks. BTW, you can report bugs at http://byobugs.com
NOTE: If you are under the age of 13, please do not create an account, and log in with the username: "guest@byobugs.com" and the password: "password" (without the quotes) instead.
Offline
bharvey wrote:
EDIT: PPS: Congratulations!!! And demosthenes too!! Good thing this isn't like real-world elections, where the people I vote for always lose.
Hey bharvey,
Thanks for congratulating me. However, you should be aware that congratulations are offensive to some people. Please review the Terms of Use before doing something like that again in the future. Scratch On!
^ I'm practicing my "official voice"
I'm glad your candidate won for a change!
Offline
fullmoon wrote:
Looks like I should go review the Terms of Service.
No, no, my uparrow was pointing to the rolleyes, not to the quote from you. (It actually took me a while to understand your reply, since I knew what I meant.)
EDIT: The point being, if they interpreted the ToS that sensitively, they'd edit the repertoire of smileys!
Last edited by bharvey (2010-10-22 20:57:23)
Offline
bharvey wrote:
fullmoon wrote:
Looks like I should go review the Terms of Service.
No, no, my uparrow was pointing to the rolleyes, not to the quote from you. (It actually took me a while to understand your reply, since I knew what I meant.)
Ah! It's amazing how things can be misinterpreted through online communication.
Offline
@shadow: Hey, if you're in Dallas 7pm Fri 3/11/11 you can help teach our workshop for teachers at the conference!
Offline
Good catch, fullmoon, and congratulations, too!
bharvey wrote:
Oh oops, the notation is different for lambdas? I see, it's supposed to remind you of the "such that" in set notation? I get it.
Don't worry, Brian, most Smalltalkers aren't even aware that there are things like formal parameters for lambdas in Smalltalk, because, funny thing is, most Smalltalkers don't ever declare lambdas themselves, instead we're mostly always using selectors of formally declared methods, as in
#(foo bar baz) do: [ :selector | someObject perform: selector ]
because, you know, Smalltalk really is about sending messages to objects, and not about directly invoking object properties which just happen to be functions. (It's only by being exposed to weirdo functionalists that we become infiltrated by the dark side of the force )
Last edited by Jens (2010-10-24 19:46:44)
Offline
Jens wrote:
Code:
#(foo bar baz) do: [ :selector | someObject perform: selector ]
That's still a lambda with a formal parameter (selector)!
I wish there were a \mapsto symbol in ASCII (looks sort of like this: |-> a right arrow with a vertical bar at its tail), which is the correct symbol for putting formal parameters before an expression to make a function. Then I'd have understood it the first time.
Offline