This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#4851 2012-03-20 12:22:05

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

joefarebrother wrote:

Not if it copies what is in foo into a list and then adds that to foo so foo would be
list( (thing) (list( (thing) ) )

But it's not just two levels deep!  You can say

ITEM (1) OF (ITEM (2) OF (ITEM (2) OF (ITEM (2) OF (ITEM (2) OF (ITEM (2) OF (ITEM (2) OF (ITEM (2) OF (ITEM (2) OF (ITEM (2) OF (FOO))))))))))

and you'll still get the (correct) answer "thing"!

but if the add block copied the list instead of adding a reference, but it added it AFTER copying not before, there will be no infinite loops


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4852 2012-03-20 14:56:45

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

but if the add block copied the list instead of adding a reference, but it added it AFTER copying not before, there will be no infinite loops

Well, for our purposes, sometimes the user wants a self-referential data structure.  Also, even if not, the user usually wants a later change in a sublist to be reflected in the list-of-lists.  So copying isn't a good option; the user can make a copy explicitly if desired.

Maybe Scratch could do lists of lists with copying.  It would be weird,  I think.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4853 2012-03-20 21:38:31

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Hardmath123 wrote:

It's a simple Scratch implementation which does use the DOM stuff for text boxes, etc.

It's Jens who's reluctant to use the DOM, so I'll leave this part for him.

Also, I was thinking about making sounds first-class while you're at it.

Yes, of course, probably not in 4.0 but when we have first class costumes we'll have first class sounds too.

PS Excuse typos, please, I'm typing with one hand with a drink in the other.

Oh, no, someone who does think "BYOB" means "bring your own..."  smile

bring your own milkshake?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4854 2012-03-20 22:15:55

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

bring your own milkshake?

big_smile   Maybe if you rotate the second B 90 degrees counterclockwise.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4855 2012-03-21 03:49:40

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Hardmath123 wrote:

bring your own milkshake?

big_smile   Maybe if you rotate the second B 90 degrees counterclockwise.

And pretend it's underlined.


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#4856 2012-03-21 17:55:09

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Is there any way on byob 3.1.1 to test if a value is 'nil', the value reported when a script doesn't report anything? Because right now i am trying to make a switch block that allows you to jump between cases using a report block, but the test script has to look like this: (you need antidote to see it)
http://i41.tinypic.com/suygy8.gif
Those report blocks allow you to jump between cases so you can stockpile actions (also if you report <false> it will do the default AND the case) but you need a report <true> block to end the script, which looks ugly. If there was a way to compare values to nil, i could solve this problem. (the = boolean doesn't work) Here is my implementation:
http://i42.tinypic.com/2hxm4ja.gif
http://i43.tinypic.com/6eeult.gif
http://i43.tinypic.com/f4n50g.gif

Last edited by joefarebrother (2012-03-21 17:56:04)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4857 2012-03-21 18:29:57

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Is there any way on byob 3.1.1 to test if a value is 'nil', the value reported when a script doesn't report anything? Because right now i am trying to make a switch block that allows you to jump between cases using a report block, but the test script has to look like this: (you need antidote to see it)
http://i41.tinypic.com/suygy8.gif
Those report blocks allow you to jump between cases so you can stockpile actions (also if you report <false> it will do the default AND the case) but you need a report <true> block to end the script, which looks ugly. If there was a way to compare values to nil, i could solve this problem. (the = boolean doesn't work) Here is my implementation:
http://i42.tinypic.com/2hxm4ja.gif
http://i43.tinypic.com/6eeult.gif
http://i43.tinypic.com/f4n50g.gif

Could you test if <(action) is a (reporter)?>, and return its value, and otherwise return false? (in switch-case)

Last edited by nXIII (2012-03-21 18:30:22)


nXIII

Offline

 

#4858 2012-03-21 18:35:29

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Is there any way on byob 3.1.1 to test if a value is 'nil', the value reported when a script doesn't report anything?

Scratch (and therefore BYOB) makes a strong distinction between commands and reporters.  It's an error to CALL (rather than RUN) a block that doesn't report a value.  I just tried putting a STOP BLOCK in a custom reporter in 3.1.1 and it seems to cause an infinite loop when CALLed.

If your domain doesn't include Booleans, you could write a reporter version of SWITCH and have each case report a new value or False.  Then I'd use CASCADE to keep trying until the reported value is False.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4859 2012-03-22 02:10:51

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I'm thinking about writing a Lisp interpreter in Scratch. I've got a good foundation (see my logic circuit evaluator), but Lisp is much harder because of recursion and lambdas. I'm thinking about ignoring define and just using Let's, and tackling recursion by making the evaluator actually expand the expression until all functions are pre-defined ones.

Any advice?

EDIT: I tried it in BYOB, it worked pretty well.

EDIT2: I've also been messing with the file format, and was wondering: did you guys change the 10-byte file header to "BloxExpV01" from "ScratchV01"?

Last edited by Hardmath123 (2012-03-22 03:50:34)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4860 2012-03-22 12:50:55

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I'm thinking about writing a Lisp interpreter in Scratch.

You're a masochist!  It's (pretty) easy to write a Lisp interpreter in a language that gives you recursive procedures, but you're going to have to maintain a stack of tasks in an explicit list to simulate procedure calls.  And you don't even have lists of lists in Scratch, so you have to encode everything as text.

Doing a pure functional Lisp by substitution, as you suggest, should work fine.  If you'd like to see another way, one that even lets you implement mutation, look at the Explicit Control Evaluator in Chapter 5 of SICP.  The evaluator comes pretty late in the chapter, but you have to read all of it, because they start by essentially inventing a machine language and you have to understand that first.  The payoff is that the evaluator does tail call elimination, not to mention that you can have DEFINE.

P.S.  It's awesome that you're into Lisp.  I'm still working on convincing Jens that we should compile Snap! procedures into Lisp.  smile


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4861 2012-03-22 14:25:35

roijac_test
Scratcher
Registered: 2011-08-31
Posts: 49

Re: BYOB 3 - Discussion Thread

bharvey wrote:

I'm still working on convincing Jens that we should compile Snap! procedures into Lisp.  smile

won't it be faster to compile it to JS?

ps. another bug report  smile
dragged sprites lose their speech and think bubbles  tongue

Last edited by roijac_test (2012-03-22 15:26:38)


http://gigabyte.50webs.com/funnyerrormessages/work013.jpg

Offline

 

#4862 2012-03-22 15:50:38

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

roijac_test wrote:

won't it be faster to compile it to JS?

Well, it'll be more useful to compile to JS, in terms of getting Snap! projects to run fast, and we'll do that too.  But I don't really want to show the user the resulting JS, because it's not going to look like idiomatic JS code; it'll be all procedure calls, basically.  Whereas the result of compiling into Lisp will look like idiomatic Lisp code, because (1) Snap! is really just Scheme in disguise, and (2) all programming languages are really Lisp once you get past the surface syntax -- this is why the first thing a modern compiler does is to turn the program into a "parse tree," a/k/a a Lisp program.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4863 2012-03-22 15:56:02

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

wait, why not just show em the snap! blocks?

Offline

 

#4864 2012-03-22 18:37:27

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

roijac wrote:

wait, why not just show em the snap! blocks?

We're already doing that.  The question is whether also to have some format that's easier to write programs about.  The alternative would be to make a parse tree in list-of-blocks form, which we should do also.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4865 2012-03-23 05:33:35

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Hardmath123 wrote:

I'm thinking about writing a Lisp interpreter in Scratch.

[...]

Thanks for the... encouragement, I suppose.  tongue

After some thought, I decided to make it lamba/call only, just for convenience. Check back about two weeks later.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4866 2012-03-23 13:02:38

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

joefarebrother wrote:

Is there any way on byob 3.1.1 to test if a value is 'nil', the value reported when a script doesn't report anything?

Scratch (and therefore BYOB) makes a strong distinction between commands and reporters.  It's an error to CALL (rather than RUN) a block that doesn't report a value.  I just tried putting a STOP BLOCK in a custom reporter in 3.1.1 and it seems to cause an infinite loop when CALLed.

well sometimes it reports 'nil' which always returns false in the equals boolean (even with another nil value) and causes an error if you try to check it's type with the <Is () a ()> block, and other times it loops forever trying to report something.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4867 2012-03-23 13:09:26

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Hardmath123 wrote:

I'm thinking about writing a Lisp interpreter in Scratch.

You're a masochist!  It's (pretty) easy to write a Lisp interpreter in a language that gives you recursive procedures, but you're going to have to maintain a stack of tasks in an explicit list to simulate procedure calls.  And you don't even have lists of lists in Scratch, so you have to encode everything as text.

I thought of a mechanism to solve this: encode your "list" as a php string so an examply would be

Code:

list:item1=something&item2=somethingelse&item3=athirdthing

and if you want something with the & and = characters in it use /& and /= then you just need to write a script to interpret this and copy each item into a list so you can do the list blocks on it.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4868 2012-03-23 14:53:03

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

I thought of a mechanism to solve this: encode your "list" as a php string

Oh, yeah, it's possible; you just spend half your time encoding and decoding instead of doing the interesting work of evaluating expressions.

You could even encode it as strings of zeros and ones!   tongue


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4869 2012-03-23 14:54:40

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

well sometimes it reports 'nil' which always returns false in the equals boolean (even with another nil value)

Nil isn't a value; it's a very terse error message.  When we have time for details of the user interface, we'll improve error reporting.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4870 2012-03-23 16:40:07

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

joefarebrother wrote:

well sometimes it reports 'nil' which always returns false in the equals boolean (even with another nil value)

Nil isn't a value; it's a very terse error message.  When we have time for details of the user interface, we'll improve error reporting.

also (atribute [parent v]) of something that has no parent is nil


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4871 2012-03-23 17:31:57

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

also (atribute [parent v]) of something that has no parent is nil

I'm going to talk Jens into having a root object that's its own parent, so every object will have a parent and this won't arise.  (But the parent of a toplevel sprite will be the Sprite object, whose parent will be Corral (with Stage as its other child); Corral's parent will be Object.  Or something like that.  Other children of Object will be Costume and Sound.

But I don't think I've talked him into it quite yet.  smile


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4872 2012-03-23 18:01:31

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

joefarebrother wrote:

also (atribute [parent v]) of something that has no parent is nil

I'm going to talk Jens into having a root object that's its own parent, so every object will have a parent and this won't arise.  (But the parent of a toplevel sprite will be the Sprite object, whose parent will be Corral (with Stage as its other child); Corral's parent will be Object.  Or something like that.  Other children of Object will be Costume and Sound.

But I don't think I've talked him into it quite yet.  smile

Couldn't you then recurse infinitely if you were trying to find the toplevel parent through repeated calls to parent? Wait, maybe not...


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#4873 2012-03-24 01:16:10

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

Couldn't you then recurse infinitely if you were trying to find the toplevel parent through repeated calls to parent? Wait, maybe not...

The OBJECT block in Sensing will have "Root Object" as one of the menu choices, so you'll be able to say

IF <(OBJECT (parent)) = (OBJECT (Root Object))> ...

Last edited by bharvey (2012-03-24 01:17:17)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4874 2012-03-24 02:47:33

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

joefarebrother wrote:

also (atribute [parent v]) of something that has no parent is nil

I'm going to talk Jens into having a root object that's its own parent, so every object will have a parent and this won't arise.  (But the parent of a toplevel sprite will be the Sprite object, whose parent will be Corral (with Stage as its other child); Corral's parent will be Object.  Or something like that.  Other children of Object will be Costume and Sound.

But I don't think I've talked him into it quite yet.  smile

maybe any toplevel sprite is the parent of itself?


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4875 2012-03-24 12:56:41

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

maybe any toplevel sprite is the parent of itself?

Well, this is the part I haven't talked Jens into, but I want a complete object hierarchy with Object at the beginning.  So there should be a Corralable object (a class, if you want to think of it that way) whose children include both the stage and the generic Sprite object, etc.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

Board footer