Hi, I would like to cover assignment set operator with a nice "=" .
That does - of course - not work. I have to declare/make a variable and then use it. So I cannot have a variable as a variable in my own block.
But any ideas how to achieve something similar ??
BTW: This is part of a project in programming in exactly same wording as in python
Try this with type of variable: any (unevaluated):
Ich bin sicher das wird funktionieren. Ich bin einfach nicht drauf gekommen...
One of the libraries defines 'let' as follows. Note the uppvar option is selected.
Thank you so much!!! Now I know what the Upvar option is for!
Sorry but you've pushed one of my buttons. "=" is a terrible symbol for assignment, because it already has a meaning, one that every kid in a programming class already knows, namely, it's a predicate that reports true if its two inputs are the same value. If you add up all the grief that all the kids have had over things like
x = x+1, you see how truly evil it is to confuse them about what = means.
If you have to do something like that, please use "←" which is the correct symbol for assignment. Now that we have Unicode it's pretty easy to use that symbol, but if you have to use something on the ASCII keyboard, at least pick ":=" or some such thing. Or "<-".
Yes, I read the part about simulating Python, but do you really have to simulate its evil parts? It's not the case that "typing languages" as you call them all do it. APL uses ←. Lisp uses (setq var val). Algol uses ←. Pascal uses :=. Only evil languages use =.
I know that "=" is evil I liked Pascal ":=". Pascal is not that evil, but it lacks functional and OO programming a bit.
To my defense: I am not doing Python - code generation for beginners. This is for kids, who have done a lot with SNAP and move on. Or are forced to move on. So the grief is limited!
We all have to grow up some day.
Not me, I proudly have never grown up. I confess to having taught some high school kids C, back in the day, because we were on a Unix system, and in Unix the grownups program in C, so the kids insisted. But what I wanted to teach them, and did teach the ones who didn't insist otherwise, was Logo, in which you say MAKE var val.
But when I'm writing a program, rather than modifying someone else's program, I use Scheme, or Logo, or Snap!. Those are the real grownup languages! (Or very rarely, for ugly one-time-use things, I use awk.)