bharvey wrote:
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.
You're right. Here (not ASCII, I know, but Unicode is better anyway [/blocks]): ↦
I'm assuming you mean something like: a, b ↦ a^2 + ab
Last edited by nXIII (2010-10-25 16:13:56)
Offline
nXIII wrote:
Unicode is better anyway
Yah, except that the world's programming languages, such as for example Smalltalk, are designed in ASCII, so no mapsto character in lambda expressions (and no lambda, while I'm complaining ).
Offline
bharvey wrote:
nXIII wrote:
Unicode is better anyway
Yah, except that the world's programming languages, such as for example Smalltalk, are designed in ASCII, so no mapsto character in lambda expressions (and no lambda, while I'm complaining ).
Ah. Very true
Offline
zorket wrote:
How did you code the C block that fits into strings? Or, did you?
Well, what I did--in my not-quite-finished (haha, not quite...) quest to recreate closures--was create a subclass of ReporterBlockMorph and do a bit of copy-paste-edit from CBlockMorph for nested blocks. You next need to edit the blockAttachPoints: method so that it will allow dropping of command blocks inside a block argument. Some special-form methods in ScratchProcess plus (maybe) a new class and some edits to UpdatingStringMorph (for display purposes) and a new class for scoping (okay, this might be going a bit too far) will get you closures. Then another special-form block (and maybe a new MultiArgMorph like Jens's) "CALL" will give you evaluation OF the closures. I think that's about it. (did I miss anything, Jens?)
Offline
That gave me an idea! I'm getting a little smart at this. I've figured out something new, but the only thing I have really figured out was to make all C blocks fit into strings. Discuss more situations here.
Answer:
add this code in scratchBlocks > CBlockMorph > all > add a code:
isReporter ^ true
THANK YOU!!!
Last edited by zorket (2010-10-27 16:49:11)
Offline
zorket wrote:
That gave me an idea! I'm getting a little smart at this. I've figured out something new, but the only thing I have really figured out was to make all C blocks fit into strings. Discuss more situations here.
Answer:
add this code in scratchBlocks > CBlockMorph > all > add a code:Code:
isReporter ^ trueTHANK YOU!!!
Glad I could help
Good luck!
Offline
Offline
mortrop wrote:
What is BYOB3?
BYOB is a programming language based off of Scratch that adds support for custom blocks, first-class lists, and first-class scripts. At its heart, BYOB lets you put blocks into other blocks, which show up in the blocks palette:
Creating a new block is really simple. Right-click the scripts area and choose "Create a block". You can give the block a name and then snap blocks into the custom block area.
You can also allow your block to take inputs. For instance, the "say" block takes one input, a string of text, and then displays it in a speech bubble. When in the block editor, you can mouse over the custom block's name. You'll see some plus signs in between words, which you can click to add an input there. There are various types of inputs, so if you're not sure it's never a bad idea to chose "any":
This creates a reporter block that you can use just like any other:
Blocks can also report values. Here is an exponent block that takes two integers and then reports a calculation that happens between them:
You will also quickly notice the "the script" and "the block" blocks. These blocks are both reporters that report the script inside of them! This means you can assign a script to a variable, or add it as an index of a list. You can then "run" or "launch" a script or "call" a block. Running a script will wait for it finish executing...
...but launching won't:
Because BYOB's scripts and blocks can be assigned to a variable, passed to a block, and returned from a function, they are first-class scripts. In addition to taking inputs, scripts built with the "the script" block can also report values just like custom blocks:
Notice the little arrows on the end of "the script" and "the block". Clicking these will add input variables to these first-class scripts. You can click an input variable to change its name. The "run", "launch", and "call" blocks all have little arrows on them. By clicking those, you can add slots to the block that will pass their contents to whatever is being run, launched, or called.
You'll have noticed the "script variables" block -- it simply creates variables that are local to the current script. This should go at the top of every script to make sure its variables are usable.
Besides first-class scripts, BYOB also adds first-class lists to the mix. In BYOB, you'll see a (list) reporter with an arrow that lets you add items to it. This will report a list just like any you might create with the "Make a list" button.
You can add first-class lists to anything, even other lists.
Custom blocks can have special input slots that only accept lists:
After a while, you'll get the hang of BYOB and you can make something cool like this:
If you understand that, you understand most of what BYOB is about! There's so much you can do with it beyond the obvious, so check out the BYOB3 page for examples, tutorials, etc. Happy BYOBing!
Last edited by fullmoon (2010-10-30 19:35:14)
Offline
Wow fullmoon! That should be the default "What is BYOB3?" answer!
@henley: He/she is a new Scratcher. It's cool that he/she is interested in BYOB3!
Offline
shadow_7283 wrote:
Wow fullmoon! That should be the default "What is BYOB3?" answer!
@henley: He/she is a new Scratcher. It's cool that he/she is interested in BYOB3!
I...sort of accidentally wrote all that. Wow. I just felt I couldn't explain one part without explaining the rest.
Offline
fullmoon wrote:
I...sort of accidentally wrote all that. Wow. I just felt I couldn't explain one part without explaining the rest.
Awesome accident! I need to play with BYOB more.
Last edited by JTxt (2010-10-28 23:30:52)
Offline
fullmoon wrote:
BYOB is a programming language based off of Scratch...
Wow! (This thread seems to be provoking a lot of "wow"s. ) Thanks for taking the time to write all that, and also for caring enough about BYOB.
One teeny little infelicitous turn of phrase -- I'm pretty sure that you actually understand it correctly, but you put this in an ambiguous way:
When a script or a block can be assigned to a variable, it's called a first-class script.
This makes it sound as if some scripts are first class and others aren't. First classness is a property of a data type, not of a particular instance of that type. In BYOB, scripts and blocks are first class. That means that scripts and blocks in general can be the value of a variable, an input to a block, reported by a block, or a member of a list, even if a particular project doesn't use a particular script or block in those ways.
Offline
bharvey wrote:
One teeny little infelicitous turn of phrase -- I'm pretty sure that you actually understand it correctly, but you put this in an ambiguous way:
When a script or a block can be assigned to a variable, it's called a first-class script.
You're right, this is a little ambiguous. I was referring to the data type in general, but I didn't say so very well.
Offline
Jens wrote:
My jaw just dropped to the floor, fullmoon! This is such a definitive epic explanation that I'm reluctant to post anything after it, besides that I totally love it. Thanks!
I fully agree with your comment,Jens, fullmoon is really a Byob Master ! Respect !
Offline
fullmoon wrote:
so check out the BYOB3 page for examples, tutorials, etc.
I'm sorry to be so fussy, fullmoon, but this link doesn't work. "Berkeley" has only one "l". (Gotta learn how to spell it if you're going to be a student here. )
P.S. Check out this suggestion in the suggestions forum inspired by your post.
Last edited by bharvey (2010-10-30 19:11:32)
Offline
bharvey wrote:
fullmoon wrote:
so check out the BYOB3 page for examples, tutorials, etc.
I'm sorry to be so fussy, fullmoon, but this link doesn't work. "Berkeley" has only one "l". (Gotta learn how to spell it if you're going to be a student here. )
P.S. Check out this suggestion in the suggestions forum inspired by your post.
Thanks for catching that! What a stupid typo...I don't even think it's possible to pronounce "Berkelely". Surely part of the application screening process at Berkeley is making sure that potential students spelled it right.
Maybe in the name of competitiveness you should rename your school to something that's impossible to spell wrong, like MIT.
Offline
You know? I've been using BYOB for a long time, and I'm really good with it, but I still don't understand what makes something first class.
Offline
I have to say, Scratch Suggestions has really frustrated me.
The chronic theme of the site certainly isn't programming.
It seems like people want Scratch to evolve in to a YouTube-type website. It's frustrating. Scratch seems to be slipping away from the emphasis on programming it once had. This isn't the first time I've observed this, but it has become more and more noticeable as time progressed. It seems as if it can only get worse.
I think the Scratch program is awesome, but I'm sick of seeing the "high ceiling" continuously slip lower. That's why I'm turning to BYOB3. Jens and bharvey, don't let me down!
Offline
ScratchReallyROCKS wrote:
You know? I've been using BYOB for a long time, and I'm really good with it, but I still don't understand what makes something first class.
Okay, first, let's reiterate the official definition: A data type is first class in a language if an instance of that type can be
* the value of a variable;
* an input to a procedure (Scratch: block);
* the value returned (Scratch: reported) by a procedure;
* an element of a data aggregate (Scratch: list).
So now, as an example, let's look at lists. In Scratch, make a list. You have to give it a name, let's say FOO. Now put some items into FOO, like ABC and DEF and 23. Now make a variable, ZOT, and run the block SET <ZOT> TO <FOO> (dragging the red FOO oval into the SET block). The new value of ZOT will not be a list of three items ABC, DEF, and 23; instead, it'll be the string "ABC DEF 23". Scratch doesn't let a list be the value of a variable.
Now do the same thing in BYOB. This time, the value of ZOT will actually be the list FOO! You can see it in the monitor that displays ZOT on the stage. Thus we see that a list can be the value of a variable.
Similarly, in BYOB you can make a block that takes a list as input, and/or reports a list. (Of course in Scratch you can't make blocks at all, but it's worth noting that none of the built-in blocks take lists as inputs or report a list.) And you can use a list as an item in another list.
Another point that I've seen in some books as part of the definition of first class, but not others, is that the data can exist without having a name. In Scratch, you click Make a list, and the first thing that happens is that you're asked what to name it. You can do that in BYOB, too, if you want, but you can also use the LIST block to make a list by saying what its contents should be, but not giving it a name, e.g., [SAY [LIST <1> <2> <3>]]. You create a list and use it as input to the SAY block, and it never has a name.
So this is why we say that lists are first class in BYOB but not in Scratch. (The data types that are first class in Scratch are just numbers and text strings. Booleans would be included, too, but in Scratch there really isn't a separate Boolean type; instead sometimes they use the text strings "true" and "false" and sometimes they use the numbers 1 and 0 respectively.)
The other data type that's first class in BYOB but not in Scratch is procedures (blocks and scripts). But this post is long enough already.
Offline