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

#6026 2012-10-01 17:15:27

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: BYOB 3 - Discussion Thread

@shadow_7283 - Aww... Ninja'd.
xD


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#6027 2012-10-01 17:19:27

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

Re: BYOB 3 - Discussion Thread

Jens wrote:

And yes, everything will be incredibly clever, of course!  smile

I forget who said this, some software engineering guru, but since it's harder to debug code than to write it in the first place, if you write code as cleverly as you can, then you can't debug it!

So, you mean, everything will be incredibly standard and built out of off-the-shelf components whenever possible, right?  smile


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

Offline

 

#6028 2012-10-01 21:38:10

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I never noticed that setting a variable equal to a list in BYOB 3 isn't a one-time action, all changes that are made in the list are then reflected in the variable from that point forward. Is there someway to prevent this behavior?
EDIT: I thought "Copy of" would do the trick, but I suppose I was wrong.

Last edited by shadow_7283 (2012-10-01 21:39:57)

Offline

 

#6029 2012-10-02 00:03:50

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

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

Is there someway to prevent this behavior?
EDIT: I thought "Copy of" would do the trick, but I suppose I was wrong.

"Copy of" will do it unless you have a list of lists; "Copy of" does only a toplevel copy, so sublists are still identical in the two versions.  You can write your own "Deep copy of" that recursively copies sublists.

I'm a little surprised that you want a deep copy, though; that's unusual.

PS  It's not that the variable changes when you change the list.  The value of the variable is a pointer to the list; that pointer remains constant even as the contents of the list change.  Technically every value is a pointer, but you can't tell the difference unless the thing pointed to is a mutable structure.  For instance, if there were a "Replace letter (n) of (string) with (letter)" command, the same issues would arise with strings.

EDIT:  I keep bugging Jens for a version of = that tests pointer equality (EQ?) rather than value equality (EQUAL?), but we need suggestions about a good name for it.  IDENTICAL? is one semi-standard name, but I'm not sure it's self-explanatory if you don't already know.  I'm almost tempted to call it ENTANGLED?, as in quantum entanglement, where changing one particle magically changes the other one, but I'm not sure that passes the obvious-to-an-eight-year-old test.  And technically entanglement is different because there really are two separate particles, whereas there's only one list if the two inputs are EQ?.

Last edited by bharvey (2012-10-02 00:11:31)


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

Offline

 

#6030 2012-10-02 01:30:56

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

shadow_7283 wrote:

Is there someway to prevent this behavior?
EDIT: I thought "Copy of" would do the trick, but I suppose I was wrong.

"Copy of" will do it unless you have a list of lists; "Copy of" does only a toplevel copy, so sublists are still identical in the two versions.  You can write your own "Deep copy of" that recursively copies sublists.

I'm a little surprised that you want a deep copy, though; that's unusual.

PS  It's not that the variable changes when you change the list.  The value of the variable is a pointer to the list; that pointer remains constant even as the contents of the list change.  Technically every value is a pointer, but you can't tell the difference unless the thing pointed to is a mutable structure.  For instance, if there were a "Replace letter (n) of (string) with (letter)" command, the same issues would arise with strings.

EDIT:  I keep bugging Jens for a version of = that tests pointer equality (EQ?) rather than value equality (EQUAL?), but we need suggestions about a good name for it.  IDENTICAL? is one semi-standard name, but I'm not sure it's self-explanatory if you don't already know.  I'm almost tempted to call it ENTANGLED?, as in quantum entanglement, where changing one particle magically changes the other one, but I'm not sure that passes the obvious-to-an-eight-year-old test.  And technically entanglement is different because there really are two separate particles, whereas there's only one list if the two inputs are EQ?.

How about "[] > are the same?"


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

Offline

 

#6031 2012-10-02 07:53:34

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I wanted to make a value comparison between two lists- one from an older point in time in order to test for potential changes.

Offline

 

#6032 2012-10-02 08:15:27

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

check out Snap!'s German translation experiment


Jens Mönig

Offline

 

#6033 2012-10-02 08:44:17

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

EDIT:  I keep bugging Jens for a version of = that tests pointer equality (EQ?) rather than value equality (EQUAL?), but we need suggestions about a good name for it.

IS?

@jens, es funktioniert alles ausser die drop-downs (oder wie sie auch immer heissen), z.B. left arrow, last, number/list/Boolean..., das mit dem Turtle Kostüm und dem About Text, der nicht übersetzt wurde (ob es auch sinnvoll wäre?)
gute Arbeit!

Last edited by roijac (2012-10-02 08:52:05)

Offline

 

#6034 2012-10-02 09:38:12

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

Re: BYOB 3 - Discussion Thread

Grr my edit to my post above didn't save...  sad

I never liked pointers, it was always an ugly concept to me. In my perfect world, (deep)copying would be implicit. To create a pointer, you would use a special syntax, and that variable would be a pointer object, which has the original value as a property (pointer.pointee or something). I don't know how that goes down with traditional coders, but it seems much cleaner to me.


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

Offline

 

#6035 2012-10-02 10:07:47

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

In my perfect world, (deep)copying would be implicit. To create a pointer, you would use a special syntax

That's like the C &var notation for "the address of var."

But in a really perfect world, people would program functionally, and would refrain from mutating things, and would construct a new partial list when necessary to update a value, and then the old variable would still point to the old list as shadow wants.

But, the point is, there's a difference between pointers (which are unavoidable) and making pointers visible to the user.  You need pointer variables only if some values are pointers and some aren't.  If every value is a pointer, as in Lisp-based languages, the user never has to see a pointer, because the language semantics automatically dereferences them.  Java took a step in that direction by replacing C's pointer values with reference values, but (as with a lot of Java features) they compromised about it, leaving the references user-visible.

For the kind of huge data sets seen in real-world programming these days, putting gratuitous deep-copying into a language would really slow things down a lot!


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

Offline

 

#6036 2012-10-02 16:52:12

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

shadow_7283 wrote:

Is there someway to prevent this behavior?
EDIT: I thought "Copy of" would do the trick, but I suppose I was wrong.

EDIT:  I keep bugging Jens for a version of = that tests pointer equality (EQ?) rather than value equality (EQUAL?), but we need suggestions about a good name for it.  IDENTICAL? is one semi-standard name, but I'm not sure it's self-explanatory if you don't already know.  I'm almost tempted to call it ENTANGLED?, as in quantum entanglement, where changing one particle magically changes the other one, but I'm not sure that passes the obvious-to-an-eight-year-old test.  And technically entanglement is different because there really are two separate particles, whereas there's only one list if the two inputs are EQ?.

<() exactly the same as ()>
<() updates to mutation of ()>
<() is the same object as ()>
some suggestions?

Last edited by joefarebrother (2012-10-02 16:55:14)


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

 

#6037 2012-10-02 16:55:17

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

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

bharvey wrote:

shadow_7283 wrote:

Is there someway to prevent this behavior?
EDIT: I thought "Copy of" would do the trick, but I suppose I was wrong.

EDIT:  I keep bugging Jens for a version of = that tests pointer equality (EQ?) rather than value equality (EQUAL?), but we need suggestions about a good name for it.  IDENTICAL? is one semi-standard name, but I'm not sure it's self-explanatory if you don't already know.  I'm almost tempted to call it ENTANGLED?, as in quantum entanglement, where changing one particle magically changes the other one, but I'm not sure that passes the obvious-to-an-eight-year-old test.  And technically entanglement is different because there really are two separate particles, whereas there's only one list if the two inputs are EQ?.

<() exactly the same as ()>, maybe?

too long and confusing

Offline

 

#6038 2012-10-02 18:13:41

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

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

<() is the same object as ()>

Yeah, this would be the obvious choice, except that "object" is a technical term in BYOB 3.1 (and Snap! 4.1) and lists aren't objects.  The others, maybe.

EDIT:  Hmm, maybe "is the same list as"?  Its domain could be restricted to lists.

Last edited by bharvey (2012-10-02 20:26:58)


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

Offline

 

#6039 2012-10-03 03:31:36

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

Re: BYOB 3 - Discussion Thread

maybe <() points to ()>
also, i wouldn't restrict it to lists, as sprites (clones) and scripts are also mutable.

Offline

 

#6040 2012-10-03 03:59:19

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

Re: BYOB 3 - Discussion Thread

Scripts aren't mutable (yet), right?


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

Offline

 

#6041 2012-10-03 05:31:35

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

Scripts aren't mutable (yet), right?

but it would make sense if they would be, when jens gets to scripts manipulating

Offline

 

#6042 2012-10-03 05:56:20

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

Re: BYOB 3 - Discussion Thread

roijac wrote:

Hardmath123 wrote:

Scripts aren't mutable (yet), right?

but it would make sense if they would be, when jens gets to scripts manipulating

How would you even go about representing a script as something mutable? As a list-of-lists structure?
[/offtopic]

Yeah, I agree with roijac.


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

Offline

 

#6043 2012-10-03 06:00:07

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

roijac wrote:

Hardmath123 wrote:

Scripts aren't mutable (yet), right?

but it would make sense if they would be, when jens gets to scripts manipulating

How would you even go about representing a script as something mutable? As a list-of-lists structure?
[/offtopic]

Yeah, I agree with roijac.

list of callables (blocks, lambdas, etc.)

Last edited by roijac (2012-10-03 06:00:24)

Offline

 

#6044 2012-10-03 12:27:42

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

How would you even go about representing a script as something mutable? As a list-of-lists structure?
[/offtopic]

Not offtopic at all.  Yes, lists of lists of values, including procedure values.  But that isn't actually the internal representation of a script, so I envision a SCRIPT->TEXT block whose input is a script, reporting a list, and a TEXT->SCRIPT block that does the opposite.  Or perhaps, as in Logo, a DEFINE (name) (text) block that makes a new block in the current scope from a list-of-lists.  But, note, this means that scripts themselves would not be mutable.  You'd turn the script into a list, mutate that, and create a new script that might replace the old one as the definition of a block.

Sprites, though, are a better argument, since they have local state variables and are therefore already mutable.

The trouble with () POINTS TO (), in my mind, is that it suggests an asymmetry: the left input has data type "pointer" and the right one doesn't.  COLOCATED WITH says exactly the right thing, but it's a mouthful.  Maybe we should just stick with EQ? or, for non-Lispers, ==.


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

Offline

 

#6045 2012-10-03 12:43:38

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Hardmath123 wrote:

How would you even go about representing a script as something mutable? As a list-of-lists structure?
[/offtopic]

Not offtopic at all.  Yes, lists of lists of values, including procedure values.  But that isn't actually the internal representation of a script, so I envision a SCRIPT->TEXT block whose input is a script, reporting a list, and a TEXT->SCRIPT block that does the opposite.  Or perhaps, as in Logo, a DEFINE (name) (text) block that makes a new block in the current scope from a list-of-lists.  But, note, this means that scripts themselves would not be mutable.  You'd turn the script into a list, mutate that, and create a new script that might replace the old one as the definition of a block.

Sprites, though, are a better argument, since they have local state variables and are therefore already mutable.

The trouble with () POINTS TO (), in my mind, is that it suggests an asymmetry: the left input has data type "pointer" and the right one doesn't.  COLOCATED WITH says exactly the right thing, but it's a mouthful.  Maybe we should just stick with EQ? or, for non-Lispers, ==.

maybe rename <() = ()> to <() equals ()> and then we have also <() is ()>? then the difference is clearer.

#scripts, i suggest to implement scripts as lists of blocks, and make kind of (args of ()) block or something. what do you say?

Offline

 

#6046 2012-10-03 13:07:05

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

Re: BYOB 3 - Discussion Thread

roijac wrote:

#scripts, i suggest to implement scripts as lists of blocks, and make kind of (args of ()) block or something. what do you say?

Umm, well, in the abstract there's a lot to be said for that point of view, but the Morphic Way says to interweave script evaluation with the visual representation of scripts tightly, so that the actual script representation is mostly about what it looks like and only secondarily about the evaluation semantics.  So I'll let you and Jens argue about it.   smile


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

Offline

 

#6047 2012-10-03 19:19:45

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

@bharvey
" as in Logo, a DEFINE (name) (text) block that makes a new block in the current scope from a list-of-lists."
As far as I remember (30 years ago !) the DEFINE Logo procedure is composed of a header (name of the procedure), then a kind of "constructor" and the "body" made from a list (or list-of-lists)...The result is that you can change "interactively", directly from an application the nature and the role of the procedure created by DEFINE (adding or deleting items).It' s a self-adaptive custom block. This could probably be emulated in Snap! using  C-Shape like instructions.

Offline

 

#6048 2012-10-04 00:12:22

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

Re: BYOB 3 - Discussion Thread

xly wrote:

adding or deleting items

I'm not positive exactly what you mean by this.  Once you DEFINE a procedure, changing the list from which the procedure was made doesn't change the procedure, I'm pretty sure.  You can say DEFINE again to make a new procedure that replaces the old one of the given name.

One important difference between Logo and Snap! is that in a dynamically scoped language, a procedure is nothing but its text, whereas in a lexically scoped language, a procedure is the text plus the environment in which the procedure was created.  So, I guess in addition to SCRIPT->TEXT we need SCRIPT->ENVIRONMENT or something.

And maybe DEFINE should take an environment as input.  Otoh, first class environments are expensive in that certain compiler optimizations don't work if users can mess with environments.


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

Offline

 

#6049 2012-10-04 01:26:37

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

Re: BYOB 3 - Discussion Thread

How about a list-of-list structure of lambdas?

Code:

when gf clicked
say ((1)+(1))

becomes

Code:

[
 [when gf clicked],
 [say, [+, 1, 1]]
]

where +, say, and when gf clicked are actually the lambda (the () block) versions rather than text? You'll also need a (lambda = lambda?) operator, though.  hmm


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

Offline

 

#6050 2012-10-04 06:57:57

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

@bharvey
"DEFINE a procedure, changing the list from which the procedure  ..."

1 - To define -  in Apple ][ Logo - the custom block SQ you write it "by hand" in the script area.

  TO SQ  :N
  RT :N * :N
  END

2 - But you can also build this block inside your application as a list of list using DEFNE procedure :
DEFINE "SQ [[N][RT :N * :N]

3 - But DEFINE has a "reverse" procedure -TEXT -which gives the content of one custom block as a list-of-list.

TEXT "SQ returns [[N][RT :N * :N]

This list-of-list can be modified modify and then reloaded with DEFINE, and you get a new block with the same name (or another name if needed , clone, for example) which can be run directly from your application.

Offline

 

Board footer