Discuss Scratch

joefarebrother
Scratcher
500+ posts

Snap! user discussion

bharvey wrote:

joefarebrother wrote:

I fixed my try/catch block!
My example still fails.

Are you sure? I tried it and the sprite said “TypeError: list.at is not a function”.

On the other hand, I figured from reading your code that changing the name of the ERROR upvar would break it, but it doesn't.

That's because I set the variable from within the custom block, where it is always called “error”

Do you hate my proposed name change?

No, I'm just using what most progamming langauges call this construct. Feel free to change it to whatever you want if you want to add it to a library

(although be careful if you want to change the default upvar name, because you'd have to modify the JS too)

All you have to do is (define the-empty-stream '()) and test for it in MAP.

And also in stream-ref, if you wanted an error message that made sense

(Why do you capitalize function/variable names?)


And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
joefarebrother
Scratcher
500+ posts

Snap! user discussion

Turned out I wasn't logged into the cloud, so m fixed version onl exists in my localstore.

Now it should have saved.


And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
bharvey
Scratcher
1000+ posts

Snap! user discussion

BookOwl wrote:


I still don't quite get how it works.
So, you get that the first two items are 0 and 1, right? So make a table like this:
             fib-stream:  0   1   ...
(stream-cdr fib-stream): 1 ...
The remaining (infinitely many) items will be found by adding corresponding items of these two streams. Right now we only have one pair of corresponding items to add, so on the second call to stream-cdr we add 0+1 and get this:
             fib-stream:  0   1   1   ...
(stream-cdr fib-stream): 1 1 ...
Now we have enough paired items to handle another stream-cdr, which does 1+1:
             fib-stream:  0   1   1   2   ...
(stream-cdr fib-stream): 1 1 2 ...
And so on. The items of (stream-cdr fib-stream) appear just in time to allow the next call to stream-cdr.

Does that help?

liam48D
Scratcher
1000+ posts

Snap! user discussion

joefarebrother wrote:

bharvey wrote:

joefarebrother wrote:

I fixed my try/catch block!
My example still fails.
Are you sure? I tried it and the sprite said “TypeError: list.at is not a function”.
Of course - it's failing.



202e-202e-202e-202e-202e UNI-CODE~~~~~
bharvey
Scratcher
1000+ posts

Snap! user discussion

Okay, installed in library! Thanks!

PS I don't understand why there's a CALL in the LET block. Don't you want the value of RESET to be the js function itself?

PPS I capitalize words from code in text because it makes it easy for people to get that I'm talking about the code without me having to learn any fancy formatting.

PPPS I resigned from the R7RS-Small committee partly because they insisted on making identifiers case-sensitive, a massive gratuitous backward incompatibility.

Last edited by bharvey (May 23, 2016 19:15:13)


BookOwl
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

BookOwl wrote:


I still don't quite get how it works.
So, you get that the first two items are 0 and 1, right? So make a table like this:
             fib-stream:  0   1   ...
(stream-cdr fib-stream): 1 ...
The remaining (infinitely many) items will be found by adding corresponding items of these two streams. Right now we only have one pair of corresponding items to add, so on the second call to stream-cdr we add 0+1 and get this:
             fib-stream:  0   1   1   ...
(stream-cdr fib-stream): 1 1 ...
Now we have enough paired items to handle another stream-cdr, which does 1+1:
             fib-stream:  0   1   1   2   ...
(stream-cdr fib-stream): 1 1 2 ...
And so on. The items of (stream-cdr fib-stream) appear just in time to allow the next call to stream-cdr.

Does that help?
Yes, thanks!

who needs signatures
BookOwl
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

PPPS I resigned from the R7RS-Small committee partly because they insisted on making identifiers case-sensitive, a massive gratuitous backward incompatibility.
R7RS looks really complicated, for a “small” standard.

who needs signatures
bharvey
Scratcher
1000+ posts

Snap! user discussion

BookOwl wrote:

R7RS looks really complicated, for a “small” standard.
Yeah, exactly. Don't get me started on how wrong-headed R7RS is. (I think Scheme peaked somewhere around R3 or R4.)

joefarebrother
Scratcher
500+ posts

Snap! user discussion

bharvey wrote:

I don't understand why there's a CALL in the LET block. Don't you want the value of RESET to be the js function itself?

I want reset to be the function returned by the JS function, which is a closure over oldErrorHandler and oldCatchingErrors

Anyway, I think the best RnRS is either 4 or 5

I've never looked into R3RS, what are the differences between it and later versions?

R7RS is certainly better than R6RS, however

Last edited by joefarebrother (May 23, 2016 20:20:18)



And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
bharvey
Scratcher
1000+ posts

Snap! user discussion

joefarebrother wrote:

I want reset to be the function returned by the JS function, which is a closure over oldErrorHandler and oldCatchingErrors
OK, thanks.

I've never looked into R3RS, what are the differences between it and later versions?
The biggest one I remember is that in R3 the empty list is still false, as in traditional Lisps.

R7RS is certainly better than R6RS, however
That's a lot like choosing between having an arm cut off or a leg cut off. R7 may have cleaned up some outright mistakes in R6, but it's a political disaster because it pretends to have accommodated the needs of the small-Scheme lovers.

joefarebrother
Scratcher
500+ posts

Snap! user discussion

I'd probably rather have a leg cut off then, because I could still use a wheelchair or a prosthetic leg, but losing an arm would mean I would lose a lot of dexterity that comes with having 2 arms.

So in this analogy, R7 is losing a leg, and R6 is losing an arm, right?


And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

BookOwl wrote:

What's wrong with imperative code?
Nothing:

Jonathan50 wrote:

No, but tail-recursion doesn't need state to change. I could have said “And tail recursion is better than looping because for a while loop to terminate there needs to be state.”

BookOwl wrote:

EDIT: @jonathan50, your recursive solution is NOT tail recursive, it's tree recursive.
If you're talking about

Jonathan50 wrote:

function fib(n) {
  function fib_aux(n, a, b) {
    return n <= 1 ? a : fib_aux(n - 1, a + b, a);
  }
  return fib_aux(n, 1, 0);
}
is still much nicer than the looping one imo. (I know JS isn't tail call optimized but pretend it was)
it is. I didn't say the fib(n) = fib(n - 1) + fib(n - 2) one is?

Last edited by Jonathan50 (May 23, 2016 20:50:01)


Not yet a Knight of the Mu Calculus.
BookOwl
Scratcher
1000+ posts

Snap! user discussion

@Jonathan50, than why are you saying that recursion is better than looping? It can't be state because you have to maintain state in both versions, the difference is that in the recursive version you use arguments and in the looping version you use parameters.
It appeared to me that you were saying that fib(n) = fib(n - 1) + fib(n - 2) is tail recursive. Sorry for misunderstanding you.

who needs signatures
bharvey
Scratcher
1000+ posts

Snap! user discussion

I think you guys just like arguing. (Said Brian, who never argues.)

jfb: No need to lose any limbs at all. I have an R4RS running on my computer. So I don't have to have an opinion as to which is which.

BookOwl
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

I think you guys just like arguing. (Said Brian, who never argues.)

jfb: No need to lose any limbs at all. I have an R4RS running on my computer. So I don't have to have an opinion as to which is which.
Arguing is good! It's fighting that isn't.

I use chicken scheme, which is R5RS.

who needs signatures
BookOwl
Scratcher
1000+ posts

Snap! user discussion

The codification example has several bugs in the map to Python block.

who needs signatures
BookOwl
Scratcher
1000+ posts

Snap! user discussion

BookOwl wrote:

Project loading really needs to be made async. Every time I try to load a block library or project, my web browser says that snap! is locked up, and if I let it continue, it locks up my whole browser for one or two minutes, depending on how big the project is.
Please jens? For me and my ancient laptop?

who needs signatures
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

BookOwl wrote:

Project loading really needs to be made async. Every time I try to load a block library or project, my web browser says that snap! is locked up, and if I let it continue, it locks up my whole browser for one or two minutes, depending on how big the project is.
It makes my browser freeze, usually. Will making it run in not the main thread help?

Not yet a Knight of the Mu Calculus.
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

BookOwl wrote:

@Jonathan50, than why are you saying that recursion is better than looping? It can't be state because you have to maintain state in both versions, the difference is that in the recursive version you use arguments and in the looping version you use parameters.
It appeared to me that you were saying that fib(n) = fib(n - 1) + fib(n - 2) is tail recursive. Sorry for misunderstanding you.
For a while loop to end then state needs to change.

Not yet a Knight of the Mu Calculus.
BookOwl
Scratcher
1000+ posts

Snap! user discussion

Jonathan50 wrote:

BookOwl wrote:

Project loading really needs to be made async. Every time I try to load a block library or project, my web browser says that snap! is locked up, and if I let it continue, it locks up my whole browser for one or two minutes, depending on how big the project is.
It makes my browser freeze, usually. Will making it run in not the main thread help?
It should.

who needs signatures

Powered by DjangoBB