Scheme style blocks in Snap!

Okay, they all seem to be un-reversed, so I'm convinced.

Umm. I'm not sure where that problem comes from.

Oh, I see, you want to allow literal text as inputs. But there isn't any text in lambda calculus! The only data type is Reporter. So I think your problem doesn't arise.

[offtopic]i'm making a command line thing, should i include something like that?

That would be good.

just one thing though... how does it actually work?

(20:08 at 2/4/2024 edit)

I made a COND block!
pic

That was similar to my reporter version of the multi-branched conditional block but that was exceptional. :smiley:

:~)

"Young adult" means 18-21? I think to librarians it means middle school (11-14) and up.

I was just trying to create a test case. I meant someone who could buy guns in America but can't drink. (Maybe half-proper American?)

Well, if we let them drink, their aim would suffer.

in the unix command line, you can use | to transfer the output of a command to another command. for example, you could run a program that outputs Hello, World! into the terminal. you could run the command like this: ./helloworld. now, i want to transfer the output of ./helloworld to another program, for example, grep, which is a program that searches for a certain string in the output you pipe to it. you would do that by typing ./helloworld | grep hello. maybe a screenshot will help:

as you can see here, i first ran the cowsay command, that prints an ASCII representation of a cow to the console saying the specified text. next, i ran it again, but this time, i piped the output to grep and told grep to search cowsay's output for hello. you can use other programs other than grep for different tasks, but I'm using it here as an example

I saw @joecooldoo's reply but want to go a level lower in abstraction. In Unix-family systems, whenever a process starts up it is given three initial ports (an abstraction to which you can send, and from which you can read, data) called stdin (standard input), stdout (standard output), and stderr (standard error). The vast majority of programs have one input data stream and one output stream; they are typically programmed to read from stdin and write to stdout. (We'll get to stderr later.)

The most common case is that a command line just runs one program. In that case, one process is started; its stdin is connected to the keyboard and its stdout and stderr are connected to the screen. (In both cases, there's a lot of software between the process and the actual hardware.)

But if you give a command of the form A | B (where A and B are things you could have typed as a standalone command), the process for A has its stdout hooked up to the stdin of the process for B. There is buffering in the connection for efficiency, so you don't have to switch processes for each character output by A.

That's how it works! Note that A's stderr, which is meant to be used for error messages, is not redirected to B's stdin; it still goes to the screen. (There are other syntax elements you can use to redirect stderr if you actually want to, but usually you want the user to see error messages.) This is why stderr exists.

By the way, I hesitantly lay claim to prior work on this idea. I was at a startup, although that word hadn't been invented yet, called Composition Technology, that did computer typesetting of mathematics, before there was $$\TeX$$. My boss, Lowell Hawkinson, implemented an interprocess port abstraction, and I used it to implement a pipe-like command line notation, around 1971. Wikipedia says Unix development started in 1969 and the first public release was in 1973. This range of dates is what makes me hesitant: I don't know if Lowell had some inside scoop from Bell Labs before then, but I sure didn't. I learned about Unix when I got to LSRHS in 1979.

pic
Welp, I'm not sure what this means. G_last is defined in the global environment.

Hmm. Could you post a link again? I can't find it in all these posts! Tnx.

Sure: Snap! Build Your Own Blocks

Just as I suspected, it's due to metaprogramming. When you create a script using metaprogramming, it strips away any context variables in it had, which throws an error when you try to run it.


So you have to run the script in a sprite's context using tell or ask

All you have to do is to change call to ask, and it'll work perfectly.


Do I agree with this behavior? No, as I think the script in the call block should be able to at least access global variables no matter if the context is set or not.

A continuation of my previous problem:

pic

Currying doesn't work b/c it doesn't have the context of the outer λ. Is there anything I can do to fix this?

You may "rebind" the prepared lambda with
untitled script pic - 2024-04-07T023225.186

Yes, you can use
untitled script pic (3)

Can you give me an example?

Replace the (...) block with the script you need to call.