Discuss Scratch

bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

cycomachead wrote:

I feel I'm one of the few people around here who seems to not mind bug reports, or even dupes. I'd much rather know all the issues than miss something.
For the record, I love bug reports. I even love feature requests.

bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

So I was looking over old messages and discovered that back in 2016 there was an AT thread called “Confusion About Lambdas, Anonymous Functions and First Class Functions” that I never knew about! One of you guys shoulda called it to my attention…

scratchmouse
Scratcher
70 posts

Snap! Team development discussion, vol. 2

bharvey wrote:

So I was looking over old messages and discovered that back in 2016 there was an AT thread called “Confusion About Lambdas, Anonymous Functions and First Class Functions” snip snip
Hardmath123 concluded one of the posts in the thread:
In practice, all sorts of languages call their constructs “functions”,
when “subroutine” might be a better, generic word - that encompasses both returning and non-returning procedures.
Googling “non-returning procedures” returned (I guess I can use the word here) quite an interesting read among the hits: https://stackoverflow.com/questions/17337064/does-every-javascript-function-have-to-return-a-value about returning and non-returning procedures, void and similar things.

I have a couple of questions about Snap!

1) What would be an example of a “non-returning procedure” in Snap!?

2) Does “ignore” block have anything to do with it?

2.1) Can you give an example of using the “ignore” block in Snap!?

Last edited by scratchmouse (Sept. 22, 2018 10:50:46)


˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::
bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

scratchmouse wrote:

1) What would be an example of a “non-returning procedure” in Snap!?
Snap!, like Scratch, makes this easy: Command blocks (the ones that look like jigsaw puzzle pieces or Lego blocks) are non-returning. Reporters (including predicates) return (report) a value.

2) Does “ignore” block have anything to do with it?
2.1) Can you give an example of using the “ignore” block in Snap!?
Sure, one example I was just looking at yesterday, in the BJC curriculum, is this:

Here we are calling a reporter, not because we care about its value, but because we want to see how long it takes to process a call. (This is leading up to discussing orders of growth of time as a function of input size.)

Other than for timing, I can't offhand think of a reason to use IGNORE with a pure function, one that has no lasting effect on the state of the system. But, for example, let's say you're writing a simulation of a Magic 8-Ball™, so the user asks a question and you give a random yes-no-maybe answer. You might say
ASK AND WAIT
IGNORE (ANSWER)
SAY [ITEM OF (LIST …)]
although there's really no reason you have to call ANSWER at all.

Or, for example, the URL block is a reporter; it reports the web page returned by the site to which the URL points. But sometimes you use HTTP to communicate with a robot controller, with things like
HTTP://localhost:1234?left-motor=23
In such cases, you really don't care what value the robot controller returns, so you'd say
IGNORE (URL [HTTP://…])

Last edited by bharvey (Sept. 22, 2018 00:32:05)


birdoftheday
Scratcher
500+ posts

Snap! Team development discussion, vol. 2

I have a slightly related question. Why is the ask function a stack block and not a reporter in snap? Wouldn’t it make more sense to have a block like

(Answer to question “…”)

:-)
Hardmath123
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

scratchmouse wrote:

Hardmath123 concluded one of the posts in the thread:
Eek!
scratchmouse
Scratcher
70 posts

Snap! Team development discussion, vol. 2

bharvey wrote:

But sometimes you use HTTP to communicate with a robot controller, with things like HTTP://localhost:1234?left-motor=23

In such cases, you really don't care what value the robot controller returns, so you'd say
IGNORE (URL [HTTP://…])
I really like your third example. What about putting it in the IGNORE's contextual Help Tip?

˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::
scratchmouse
Scratcher
70 posts

Snap! Team development discussion, vol. 2

Hardmath123 wrote:

Eek!
Someone has been scared/shocked/surprised by a (computer) mouse in one's kitchen, I guess.

˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::
scratchmouse
Scratcher
70 posts

Snap! Team development discussion, vol. 2

birdoftheday wrote:

snip snip

the ASK (sprite) FOR “…”

(Answer to question “…”)
I like your idea.

Just the other day the Jens' idea to parse poems inspired (on his Facebook) a teacher from China, who parsed one written in Chinese.
Then I tried to do similarly with the two poems that I remember from my elementary school.

And I must say that the readability of the parsed poem would be improved by your idea. See picture below.

˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::
TheAspiringHacker
Scratcher
100+ posts

Snap! Team development discussion, vol. 2

birdoftheday wrote:

I have a slightly related question. Why is the ask function a stack block and not a reporter in snap? Wouldn’t it make more sense to have a block like

(Answer to question “…”)
I suppose it's for compatibility with Scratch. One can easily build a reporter block in terms of the Scratch ask stack block, after all. In the same way, C++ supports C's stdio.h (as cstdio) and adds iostream, and implementations can define iostream in terms of cstdio.

Don't like Scratch 3? Check out https://scratch.mit.edu/projects/276693738 to see why Snap! might be the replacement for you!
(** This signature is an ML signature. *)
sig
  type t
  type kumquat
  val evil_kumquat : kumquat
end

“…the keynote speaker asked the audience to indicate by show of hands, one, how many people disliked C++, and two, how many people had written a C++ program. There were twice as many people in the first group than the second. Expressing dislike of something you don’t know is usually known as prejudice.” - Bjarne Stroustrup
bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

birdoftheday wrote:

Why is the ask function a stack block and not a reporter in snap?
Inherited from Scratch. Of course you're right that it should be a reporter. Same with CREATE A CLONE OF, for which we have both. (And furthermore, it shouldn't take an input; it should just clone the sprite that runs it, and if you want a clone of something else, you use ASK (sprite) (CLONE). But Scratch doesn't have sprite-to-sprite communication other than BROADCAST.)

In the early days, we felt we had to match Scratch exactly, because we kept hoping we could convince the ST (which basically means convincing Mitchel) to adopt our ideas. We've finally given up on that, although whenever Scratch introduces a cool new feature, Jens immediately wants to copy it. So someday, sooner than “real soon now,” we'll celebrate Flag Day (search it) by introducing lots of Scratch incompatibilities at once, changing the version number in the project files, so when you load an old project we automatically translate your code to a new idiom, maybe loading a Scratch-compatibility library if necessary. One thing I'm eager to change is the Scratch idea that any non-numeric input to an arithmetic operator means zero. (I think it should give an error message.) And change the color space from HSV to HSL.

scratchmouse
Scratcher
70 posts

Snap! Team development discussion, vol. 2

And furthermore, it shouldn't take an input; it should just clone the sprite that runs it, and if you want a clone of something else, you use…
… ASK (sprite) FOR (A NEW CLONE).


Wouldn't, in this case, using TELL block be more appropriate than using ASK block? So it would be: TELL (sprite) TO (CREATE A CLONE), I guess.

Last edited by scratchmouse (Sept. 25, 2018 14:14:40)


˙˙˙ ˙˙ ˙Ignore˙ ˙˙ ˙˙˙

… .. ˇˇˇ ˇˇˇ ˇˇˇ ˇˇˇ .. …
::: :: … ˇˇˇ ˇˇˇ … :: :::
bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

scratchmouse wrote:

Wouldn't, in this case, using TELL block be more appropriate than using ASK block? So it would be: TELL (sprite) TO (CREATE A CLONE), I guess.
When you make clones, you typically want to do something with them. If it's always the same thing, you can use WHEN I START AS A CLONE, but that's sort of a kludge, and you're never quite sure about the timing – that you don't get two bricks in the same place and a gap in the wall somewhere else. So you want to say

TELL (ASK (sprite) FOR (new clone)) TO [whatever]

or maybe just ADD (ASK …) TO [clone list]. They don't do it that way in Scratch because they don't have sprites as a first class data type. But we do, and I think it's better pedagogy to encourage people to think of them that way.

Last edited by bharvey (Sept. 25, 2018 15:18:57)


bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

Quick important programming project:

Current versions of Microsoft Word and Adobe Photoshop can't read really old .doc and .psd files, respectively. Paul's old computer, on its last legs, has versions of those programs just old enough to be able to read the really old files, but to write files in a new enough format for current programs to read.

So, the project has two parts. One is to find Word and Photoshop files on Paul's disk. I think I can do that with the Unix “find” and “file” commands in a trivial shell script. The second part is to open each of the files, make a trivial change, and save each one. I'm told that the way to do that is to use Applescript. I have never touched Applescript and don't want to spend tomorrow learning how.

So, anyone with Applescript experience who can take this on? It's kind of urgent. I figure it's about 0.1 N-hr, so maybe an hour or two for one of y'all. tia…

_nix
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

bharvey wrote:

So, the project has two parts. One is to find Word and Photoshop files on Paul's disk. I think I can do that with the Unix “find” and “file” commands in a trivial shell script. The second part is to open each of the files, make a trivial change, and save each one. I'm told that the way to do that is to use Applescript. I have never touched Applescript and don't want to spend tomorrow learning how.
Wow! Only an hour or two? You don't give us much time!

Once you've used “file” and “find” to make your script which finds all Photoshop files, you can at least compile them into a single archive and back that up onto some other computer. That way 1) you won't lose the files when Paul's computer goes kapoot, and 2) if you somehow manage to break the files via the Applescript you write, you'll have a backup ready.

I'm not too sure I can help much with the Applescript side of things, but I'll try a little… You say you need to make a “trivial change” – what exactly does that change look like? Also – this might sound really weird but – do you need the old versions of Word/Photoshop to make that change? If you do, well, then it's high priority, because once Paul's computer passes, you won't have access to the old versions. But if you don't need them, you'll be able to use the backup, and change the files by using another computer. Hopefully it's the latter, because it means we won't need to worry about doing the hard part NOW.

art blog – My pronouns are they/them, btw. sparrows one word to the paragraph
s2online: Run Scratch 2.0 in your browser; edit and back up any 1.4 or 2.0 project.
HK Scenery: WIP Hollow Knight-inspired adventure project!
HK Parallax & Toolbox: I wrote a lot of code to deal with clones! And then I wrote a lot of text discussing it here!
_nix
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

Oh, PS, you can probably use a Finder “smart folder” to find the Photoshop/Word files. I don't have a Mac at hand (I've been running Debian/Linux lately), but the basic idea is you do “file -> new smart folder” (or maybe just type something in the Cmd-F search bar…), then set the filter so that it only finds files with the psd/docx/whatever file extension. I think you click a “+” button on the side of the search results to do that. You'll also want to click “On my Mac” instead of “in my ~/Documents” or whatever, so that it finds the type of files you're looking for anywhere on your computer.

art blog – My pronouns are they/them, btw. sparrows one word to the paragraph
s2online: Run Scratch 2.0 in your browser; edit and back up any 1.4 or 2.0 project.
HK Scenery: WIP Hollow Knight-inspired adventure project!
HK Parallax & Toolbox: I wrote a lot of code to deal with clones! And then I wrote a lot of text discussing it here!
bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

_nix wrote:

You say you need to make a “trivial change” – what exactly does that change look like?
Sorry I wasn't clear. You change anything in the file and then change it back, so that the program thinks it has to save the file when you tell it to. Like the Unix “touch” command.

For simplicity, we will name three versions of Word:

Word 1 – the really ancient version in which Paul created these files in the first place

Word 3 – the current version, which doesn't know how to read Word 1 files

Word 2 – the intermediate version, on Paul's old computer, which can read Word 1 files and convert them to Word 2 format.

Luckily, Word 3 can read Word 2 files. So once we use Paul's old computer to convert to Word 2 format, we then use a new computer to convert to Word 3 format. It's the software, not the data, that's trapped on the old computer. (And no, we can't install Word 2 on a new computer.)

P.S. I suppose my estimate of 0.1 N-hr could be way off, but you should feel complimented that I only multiplied by 10 to get you-hours!

P.P.S. Sadly, the extensions aren't all correct; don't ask me why. The “file” command looks at the actual data in the file to figure out its type.

Last edited by bharvey (Oct. 5, 2018 03:21:30)


cycomachead
Scratcher
100+ posts

Snap! Team development discussion, vol. 2

apple script and those apps are a bad combo.

My advice, just image the disk. Always just have mountable images of disks

Then find an old VM if you need to, but I'm not sure there's an easy way to automate this, especially if you do need to modify the file or do a save as with a non-default format. It's possible to script but I've never pushed myself hard enough to get it to work.
comp09
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

I've found that LibreOffice can open really old Microsoft Word documents, and it does so fairly well.



Visit the website of Andrew Sun!


bharvey
Scratcher
1000+ posts

Snap! Team development discussion, vol. 2

comp09 wrote:

I've found that LibreOffice can open really old Microsoft Word documents, and it does so fairly well.
Thanks, we'll try that out!

Powered by DjangoBB

Standard | Mobile