EvilGenius wrote:
I was thinking about trying to implement one of my favorite programming constructs, call-with-current-continuation, in BYOB.
We're way ahead of you!
It's a primitive in the coming Snap! 4.0.
But call⁄cc doesn't actually remember variable values; it remembers binding locations (environments), whose values can be changed by mutation (set!). So our call⁄cc doesn't have to make copies of all the sprite variables; that's not part of its contract. You could make an argument that it should remember which sprite it's talking to; I hadn't thought that through. (Jens? Will the currently active sprite be part of the environment when we have multiple sprites in Snap!?)
Great to find another Schemer here!
Last edited by bharvey (2011-12-26 18:32:50)
Offline
bharvey wrote:
EvilGenius wrote:
I was thinking about trying to implement one of my favorite programming constructs, call-with-current-continuation, in BYOB.
We're way ahead of you!
http://cs.berkeley.edu/~bh/callcc.png
It's a primitive in the coming Snap! 4.0.
But call⁄cc doesn't actually remember variable values; it remembers binding locations (environments), whose values can be changed by mutation (set!). So our call⁄cc doesn't have to make copies of all the sprite variables; that's not part of its contract. You could make an argument that it should remember which sprite it's talking to; I hadn't thought that through. (Jens? Will the currently active sprite be part of the environment when we have multiple sprites in Snap!?)
Great to find another Schemer here!
Although I don't entirely understand call/cc yet it looks pretty cool
Offline
roijac wrote:
http://i.imgur.com/8qcVN.png
3D! :DD
install rookwoods script to view this
EDIT: two weeks without any changes - are you no longer working on the nasciturus, or just taking a break?
Why should Jens stop working on Snap! after so much work for him?
Offline
rookwood101 wrote:
I don't even understand what the warp does
As in Scratch, each Snap! thread yields control so another script can run whenever it reaches the bottom of a loop. This is why, for example, you can say
FOREVER
TURN 15 DEGREES
FOREVER
MOVE 10 STEPS
(those are two separate scripts running in parallel) and what you see is a perfect circle, because the first FOREVER runs its script once, then the second FOREVER runs its script once, etc. (There's a lot more to be said about script synchronization in Scratch; it's one of the several amazing pieces of design work by the Scratch Team that you never notice because it does exactly the right thing. But this is enough for our purposes right now.)
Frequent and controlled yielding by scripts in Scratch is absolutely the right thing in every situation, because you can't write reporters, and you generally want command scripts to pause pretty often not just for other scripts, but to allow the redisplay of sprites, so that they move smoothly instead of just jumping to wherever they belong at the end of your program without showing you the intermediate steps.
But in Snap! you can write very complicated reporter scripts (or, what comes to the same thing, very simple scripts that behave in complicated ways because of recursion) and you don't want pauses all through them; you want to compute the desired value as quickly as possible.
So, what WARP does is to make its enclosed script run all at once, without ever yielding. (Well, actually, just in case it runs forever, we force it to yield every 10 seconds or so. But that's a long time for a computer.)
Simple example if the above doesn't make sense: Try
REPEAT 100
MOVE 1 STEPS
and then try
WARP
REPEAT 100
MOVE 1 STEPS
The first one will glide across the stage; the second will just jump, even though supposedly the sprite is still taking 100 separate steps. And this happens because the non-WARP version pauses after each time through the REPEAT to allow redrawing, while the second doesn't pause until it's all done.
PS That picture-drawing script is awesome, besides finally getting me to download Greasemonkey. :-)
PPS No, Jens hasn't stopped working on Snap!. but every once in a while he does have to pay attention to the rest of his life for a while! Plus recently his computer died.
Offline
bharvey wrote:
(long explanation of "warp")
Wow! I haven't been looking into Snap! that much (why is the exclamation mark necessary? ), but that's a very nice feature, now that I hear about it!
Offline
Lucario621 wrote:
why is the exclamation mark necessary?
Hi! Long time no see.
Oh, I don't know, maybe nobody will like it except me, but "Snap" is such a generic name (try Googling it) and also this makes it kind of onomotopoetic.
WARP isn't really so new; it's just a way to get Scratch's turbo mode with more control over what's pause-free and what isn't. And it's equivalent to the "atomic" check box in BYOB. Jens invented it back before there was even a beginning of a block editor in Snap! so that people could run interesting programs fast without a new user interface feature.
Offline
*gasp* A link to Snap! in the top post!
Offline
bharvey wrote:
PPS No, Jens hasn't stopped working on Snap!. but every once in a while he does have to pay attention to the rest of his life for a while! Plus recently his computer died.
just wanted to know if he's just taking a break or working on alpha
Offline
bharvey wrote:
stuff
I thought it was going to be a very complicated programming concept (like call/cc) but it's just a very useful feature, so thanks!
PS thanks
PPS we can only hope it will be fixed/replaced soon!
Offline
rookwood101 wrote:
bharvey wrote:
stuff
I thought it was going to be a very complicated programming concept (like call/cc) but it's just a very useful feature, so thanks!
PS thanks
PPS we can only hope it will be fixed/replaced soon!
?
Offline
roijac wrote:
rookwood101 wrote:
bharvey wrote:
stuff
I thought it was going to be a very complicated programming concept (like call/cc) but it's just a very useful feature, so thanks!
PS thanks
PPS we can only hope it will be fixed/replaced soon!?
His computer.
Offline
bharvey wrote:
rookwood101 wrote:
PS thanks
OTOH now when I go to a forum page Firefox says it's "not XSS secure."
Did you install his script, and then view some page that had code in it to do that?
Offline
scimonster wrote:
Did you install his script, and then view some page that had code in it to do that?
No, just the Scratch forum -- this very topic, in fact. If the rest of you aren't seeing it, maybe it's because I have NoScript installed.
Offline
@bharvey & Jens
In the good old days Byob had a "compile" feature.
It seems that it does not work with recent OOP extensions.
Anyhow, my question is now for Snap! : is it possible to compile one Javascript application into one executable *.exe ?
Offline
bharvey wrote:
scimonster wrote:
Did you install his script, and then view some page that had code in it to do that?
No, just the Scratch forum -- this very topic, in fact. If the rest of you aren't seeing it, maybe it's because I have NoScript installed.
you might have to update the script, the newer version is much more secure.
Offline
xly wrote:
@bharvey & Jens
In the good old days Byob had a "compile" feature.
It seems that it does not work with recent OOP extensions.
Anyhow, my question is now for Snap! : is it possible to compile one Javascript application into one executable *.exe ?
Snap! could save the project as an HTML page, and then you can open it in your browser. Not an .exe, but close enough. And you don't need to worry about compatibility between systems!
Offline
xly wrote:
Anyhow, my question is now for Snap! : is it possible to compile one Javascript application into one executable *.exe ?
Yep! Adobe Air
Offline
shadow_7283 wrote:
Yep! Adobe Air
Awesome, I was hoping there was something like this. Too bad it's Adobe instead of free (as in freedom) software, but I'll take what I can get.
(EDIT: OMG did you actually read the license agreement before you clicked "I agree"? We should have one like that for Snap!: "The University of California is located in California, unless you obtained this software in Germany, in which case the University of California is located in Ireland.")
(EDIT 2: Okay, I'm confused. The web page about how wonderful AIR is talks about how to develop apps for iOS and Android, but the license agreement specifically prohibits running AIR on mobile devices. What's up with that?)
World tour update: Jens will be here next week! We are going to get so much done!
Last edited by bharvey (2012-01-04 00:47:25)
Offline