Why doesn’t this LET function work

I tried making a LET block but for some reason I keep getting this error
Here is the definition
Purely Functional Snap! script pic 3
Purely Functional Snap! script pic 12
Purely Functional Snap! script pic 11
what it’s ment to do is declare variables with preset values and then run the script using said variables. But it keeps saying the variable doesn’t exist

My guess is that the lambda function is somehow still kind of evaluating its input (enough to throw an error) but before the “let” commands are evaluated. But the rings should on,y evaluate once called, and they are called BEFORE the action with the variables in it

This could also somehow be a some mettaprogramming shenanigans but I don’t see why

in the meantime here’s inherit and set!

(The primitive block is used here as we don’t want to add a new stack block for making variables because that goes against what this is for)

I’m getting somewhere but I’m very very very very confused right now

If you wanna know why, here’s the definition..
Purely Functional Snap! script pic 17
Purely Functional Snap! script pic 3
The part of the script that is making the error, literally does not exist in the block

I fixed, however I want the “(a) be (input)” block pullouts to be rings and not normal inputs
Purely Functional Snap! script pic 19

I can now confirm after some test with rings, I believe the issue is that the “a” variable in the second input is Unringed causing it to get called before the rest of the block runs
Anyone know a way to stop that from happening that will still keep it as a ring?

IMAO you've been making this way too complicated.
Why not use ... ?

untitled script pic (51)

It works fine in the following script:

untitled script pic (53)

The only drawback is that a will persist throughout the remainder of the script, so it's existence is not confined to the action specified in the let-block. The only way to avoid that is make a separate function and create a inside the function definition. So I'm not sure if you need a let () be in () block is actually useful. You can create any variable at first use.(I'm beginning to question if what I wrote just now is not actually valid within a purely functional context)

... well, anyway, the whole let thing is just "syntactic sugar", as experts call it - you don't really need it.

I wanted it like that, however I wanted the “be” blocks to have rings for clarity of what is ment to go there
The scope shouldn’t be limited to just that block either

It’s intended for purely functional use cases, the only exception would be IGNORE
It doesn’t need to have the reporters in a ring but it would be inconsistent with everything else and lacks clarity in isolation without the other blocks that are consistent with that rule

A ringified expression can "capture" or see only variables visible in its parent script.
But (Let...) is not a parent but rather a sibling of (action).
If you use the applicative order of evaluation, i.e., regular parameters, the upvar is created in the parent context of the (action) and is accessible.

I think I debugged this for you in another thread.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.