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

#1676 2010-09-03 21:43:34

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

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

You can't create script variables based on need. For instance, if I wanted to create a variable every time the space key was pressed, I couldn't.

Ah.  Now I understand what you're asking for, but it's not clear to me how we could make this work.  The thing is, the way you use a variable is by dragging an orange blob (or maybe a brown one if you have Scope Contrast turned on) into a block.  It sounds like you want to be able to use computed variable names, but I don't see how to do that and still maintain the graphicalness of the language.

Panther allows it by having an orange oval with a text slot inside it into which you can type a name or drag an expression that computes a name.  Is that what you're after?  I suppose it's possible -- Logo does it, Panther does it, so we could too.

Scheme doesn't do it, partly for efficiency reasons and partly because of what's called "referential transparency," which basically means that it should be clear when you're writing a variable reference which variable you're going to get.  That isn't the case if another variable of the same name but a different scope might be created partway through running your program.  In the Scheme culture, you're supposed to solve this sort of programming need by using a dictionary.

I guess I'm going to abstain on this question.


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

Offline

 

#1677 2010-09-03 22:03:36

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Panther allows it by having an orange oval with a text slot inside it into which you can type a name or drag an expression that computes a name.  Is that what you're after?  I suppose it's possible -- Logo does it, Panther does it, so we could too.

I don't like this solution.
I think variables should have a drop-down menu button on the left (it won't be "embedded" like the other drop-downs) where the user can select from the following menu:

Foo
Bar
Baz
----
text

The first few are variables names, useful for using a new variable name or dragging the wrong block in. "text" lets the user type in a variable name or use a reporter (which can also be dragged onto the little drop-down arrow directly.

Demo:
     (some reporter)
(MyVar▼)
          ↑ only an area around this is the drop zone


( (some reporter)▼)

From here, if the user selects something from the drop-down the reporter will be kept in the world but moved slightly down and left from where it was and the user's selection will come up on the reporter.

Last edited by nXIII (2010-09-03 22:06:58)


nXIII

Offline

 

#1678 2010-09-03 23:33:23

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

Re: BYOB 3 - Discussion Thread

nXIII wrote:

I think variables should have a drop-down menu button on the left...

Hmm, this seems pretty complicated.  Could you explain why you prefer it?


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

Offline

 

#1679 2010-09-04 00:06:02

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

Re: BYOB 3 - Discussion Thread

I think there should be something as simple as a {create variable [] } block. That would solve the problem without too much hassle.

Offline

 

#1680 2010-09-04 01:24:23

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

I think there should be something as simple as a {create variable [] } block. That would solve the problem without too much hassle.

Then we'd need the Panther universal variable block, right?


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#1681 2010-09-04 02:00:35

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

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

I think there should be something as simple as a {create variable [] } block. That would solve the problem without too much hassle.

I went back and re-read your original post (a page ago) that started this discussion, and I realized that I don't really see how your proposed feature would help solve the problem you give as an example.

Here's the APPEND block in tools.ypr:

http://cs.berkeley.edu/~bh/append.gif

I didn't have to create variables on the fly for this; I just used a small number of fixed-name local variables.  Could you give details about how you'd use your CREATE VARIABLE block to do this?

I'm not saying this to oppose the idea; I just don't think I'm understanding what's behind it and need clarification.

Last edited by bharvey (2010-09-04 02:00:59)


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

Offline

 

#1682 2010-09-04 02:06:13

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

Re: BYOB 3 - Discussion Thread

fullmoon wrote:

Then we'd need the Panther universal variable block, right?

Right.


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

Offline

 

#1683 2010-09-04 09:59:42

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

Re: BYOB 3 - Discussion Thread

[join lists [list1] [list2] ]
set i to 1
repeat length of list1
create variable join [a] (i)
set join [a] (i) to item i of list1
change i by one

set i to 1
repeat length of list1
create variable join [b] (i)
set join [b] (i) to item i of list1
change i by one

repeat list1 + list2

Ahh... wait. I can't do that.
So yeah, I guess it wouldn't help solve this particular problem. But I still want temporary variables!

Offline

 

#1684 2010-09-04 10:46:12

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

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

I think there should be something as simple as a {create variable [] } block. That would solve the problem without too much hassle.

Have you tried to record your variables into a list (of lists), at least as a workaround. This  list acts as a "shared memory" as any sprite and any block can read/write this list.

Concerning the feature existing in Logo which allows to define "on-the-fly" a function and run it, (action + 1 = action1, action+2 = action2 etc) bharvey told me that this was incompatible with the "pick-and-stick" Scratch design.

Offline

 

#1685 2010-09-04 10:54:46

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

fullmoon wrote:

Then we'd need the Panther universal variable block, right?

Right.

Which basically turns the variable space into an array with string keys! Don't we have a library for that?  roll


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#1686 2010-09-04 11:16:17

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

Re: BYOB 3 - Discussion Thread

fullmoon wrote:

shadow_7283 wrote:

I think there should be something as simple as a {create variable [] } block. That would solve the problem without too much hassle.

Then we'd need the Panther universal variable block, right?

No! Use my block! It acts like a normal variable block, but it can accept reporters and gives you the (largely hidden) option to type into it.


nXIII

Offline

 

#1687 2010-09-04 12:29:50

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

Re: BYOB 3 - Discussion Thread

fullmoon wrote:

Which basically turns the variable space into an array with string keys! Don't we have a library for that?  roll

Indeed.  Two of them so far, yours and Rubik's.  (Well, technically, variables are a little different because they have scoping rules, whereas a dictionary is flat.  But still, basically the same idea.)

What Shadow wants is a different syntax, in which you don't have to call a block like LOOKUP <text> <dictionary> but can instead just invoke <text>.  Also he wants them temporary, meaning that they disappear when a script is done, but that can be handled by putting a dictionary in a local variable.

And I'm pleased to report, Shadow and nXIII, that BYOB can already handle the syntactic part; I just did an experiment.  Make a block, call it FOO, then in the block editor, click on the word FOO in the prototype and change it from title text to input name, of type Text.  Tada!  The Panther variable block.  (Supposing that you give it a script that looks up the text in a dictionary.)


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

Offline

 

#1688 2010-09-04 12:33:15

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

Re: BYOB 3 - Discussion Thread

nXIII wrote:

No! Use my block! It acts like a normal variable block, but it can accept reporters and gives you the (largely hidden) option to type into it.

I see, the reason you like this approach is that it discourages people from creating variable names on the fly, even while allowing it?


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

Offline

 

#1689 2010-09-04 12:41:23

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

nXIII wrote:

No! Use my block! It acts like a normal variable block, but it can accept reporters and gives you the (largely hidden) option to type into it.

I see, the reason you like this approach is that it discourages people from creating variable names on the fly, even while allowing it?

Why not include both?
One can make a variable that stays, and one is temporary!
(I discourage arguing over blocks  tongue )


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#1690 2010-09-04 12:43:15

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

Re: BYOB 3 - Discussion Thread

xly wrote:

bharvey told me that this was incompatible with the "pick-and-stick" Scratch design.

It's certainly a move in the direction of conventional text-based programming languages.  I'm pretty sure that if we proposed this as a language primitive the Scratch Team would promptly reject it as unScratchly.

But we seem to have just demonstrated that anyone who wants it can provide it as a library.  Umm, if we want an exact simulation of variable syntax, then it would be nice to be able to have a SET [text] TO (value) block distinct from the primitive SET {dropdown} TO (value) block.  Jens, what do you think about allowing overloading like that?

As for the Logo DEFINE, that's doable too, with a dictionary in which the values are scripts.

Now all we need is dynamic scope and we'll have all of Logo!  smile


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

Offline

 

#1691 2010-09-04 12:51:36

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

And I'm pleased to report, Shadow and nXIII, that BYOB can already handle the syntactic part; I just did an experiment.  Make a block, call it FOO, then in the block editor, click on the word FOO in the prototype and change it from title text to input name, of type Text.  Tada!  The Panther variable block.  (Supposing that you give it a script that looks up the text in a dictionary.)

I don't want a type-in variable reporter!


nXIII

Offline

 

#1692 2010-09-04 13:40:15

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

Re: BYOB 3 - Discussion Thread

nXIII wrote:

I don't want a type-in variable reporter!

Yeah I know, but my point is, we don't have to invent [any version of this feature because we can already do it.

So what you want us to invent is a dropdown input type for custom blocks.  smile

P.S.  Isn't the Panther variable stuff your work?


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

Offline

 

#1693 2010-09-04 13:55:08

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

But we seem to have just demonstrated that anyone who wants it can provide it as a library.  Umm, if we want an exact simulation of variable syntax, then it would be nice to be able to have a SET [text] TO (value) block distinct from the primitive SET {dropdown} TO (value) block.  Jens, what do you think about allowing overloading like that?

I asked for that before! I want that too!

In fact, just overload BYOB3 with features. Fill it to the brim!  big_smile

Offline

 

#1694 2010-09-04 14:50:24

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

Re: BYOB 3 - Discussion Thread

Okay, hashtable.ypr is an implementation of hash tables.

NEW HASHTABLE <n> reports a hash table whose size is the first prime >= n.  It says in the literature you should pick n to be about twice the number of entries you expect to put in the table.

INSERT <key> <value> <table>

LOOKUP <key> <table>


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

Offline

 

#1695 2010-09-04 16:33:06

PyrosTheStickman
Scratcher
Registered: 2009-09-19
Posts: 53

Re: BYOB 3 - Discussion Thread

Tell me whatcha think!!!!
http://scratch.mit.edu/static/icons/buddy/331910_med.png?t=2010-09-04+16%3A24%3A53

Offline

 

#1696 2010-09-04 16:34:13

PyrosTheStickman
Scratcher
Registered: 2009-09-19
Posts: 53

Re: BYOB 3 - Discussion Thread

PyrosTheStickman wrote:

Tell me whatcha think!!!!
http://scratch.mit.edu/static/icons/bud … %3A24%3A53

I think it's purdy cool.

Offline

 

#1697 2010-09-04 16:36:38

PyrosTheStickman
Scratcher
Registered: 2009-09-19
Posts: 53

Re: BYOB 3 - Discussion Thread

bharvey wrote:

xly wrote:

bharvey told me that this was incompatible with the "pick-and-stick" Scratch design.

It's certainly a move in the direction of conventional text-based programming languages.  I'm pretty sure that if we proposed this as a language primitive the Scratch Team would promptly reject it as unScratchly.

But we seem to have just demonstrated that anyone who wants it can provide it as a library.  Umm, if we want an exact simulation of variable syntax, then it would be nice to be able to have a SET [text] TO (value) block distinct from the primitive SET {dropdown} TO (value) block.  Jens, what do you think about allowing overloading like that?

As for the Logo DEFINE, that's doable too, with a dictionary in which the values are scripts.

Now all we need is dynamic scope and we'll have all of Logo!  smile

Well,whatever you're talking about,I know that some functions are impossible to create even with a program as powerful as BYOB 3.
http://scratch.mit.edu/static/icons/buddy/331910_med.png?t=2010-09-04+16%3A24%3A53

Offline

 

#1698 2010-09-04 19:16:39

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

Re: BYOB 3 - Discussion Thread

@bharvey&jens

I've entirely refurbished my Byob-Tutorial  at :
http://www.xleroy.net/ByobTuto/thumbnails.html

My experience of these last 3 months spent with Scratch&Byob is that Byob is a wonderful tool with extraordinary capabilities to write a full range of interesting, comprehensive, creative applications (broaden the walls) at the highest level possible today (raise the ceiling ).Even if it is a minor aspect of your project all applications written in Logo for 3 decades by many teachers all over the world (see Constructivism conferences in Paris ) can be easily converted (and enhanced) into Byob. On top of that Byob is now very stable with no bug detected for several weeks.

Un grand merci à tous les deux ...

Offline

 

#1699 2010-09-05 00:04:49

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

it would be nice to be able to have a SET [text] TO (value) block distinct from the primitive SET {dropdown} TO (value) block.

Hey, it turns out that you can make a custom block of that form in BYOB.  smile

So we can easily provide Panther-style variables, with a couple of caveats: (1) These variables are all essentially global, not scoped.  This can be fixed by starting a new dictionary on entry to the relevant blocks and restoring the old one on exit.  (2) These variables are separate from the ordinary Scratch-style variables.  You can't type the name of an ordinary variable into the text field and expect that variable to be set or read.


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

Offline

 

#1700 2010-09-05 10:17:10

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

Re: BYOB 3 - Discussion Thread

Those are pretty limiting factors...

Offline

 

Board footer