1 страниц (5 вхождений)
Line and Sys order of operations - Сообщения
#1 Опубликовано: 27.06.2022 14:22:16
My understanding:
sys: Allows multiple values to be assigned to a variable
line: Allows multiple calculations to be performed, only the bottom most returns a value to the variable it is assigned to
I was playing around with the above to encapsulate some complexity in a project I was working on. I struggled to get this working until I swapped the order of my line and sys operations. To my understanding this shouldn't have affected anything so I tried to come up with a minimally viable reproduction of what I was seeing (see attached)

Файл не найден.Файл не найден.
In both cases I am expecting the letter variable to be assigned a value (A=1000, B=2000), and the block to return multiple values (Works=1,2, DoesNotWork=3,4). To my understanding both of these should work as they aren't affected by the order of operations.
Works: I would expect A to be assigned the value of '1000' then '1' to be returned as the first value in the system of values assigned to 'Works' with '2' being the other.
DoesNotWork: I am expecting that B will be assigned the value of '2000', then the line will return the system of values '3,4' which is assigned to the variable DoesNotWork.
The former is working as expected but the latter is clearly not assigning 'B', so my understanding must need a little tweaking. Can anyone offer some insight? Thanks!
sys: Allows multiple values to be assigned to a variable
line: Allows multiple calculations to be performed, only the bottom most returns a value to the variable it is assigned to
I was playing around with the above to encapsulate some complexity in a project I was working on. I struggled to get this working until I swapped the order of my line and sys operations. To my understanding this shouldn't have affected anything so I tried to come up with a minimally viable reproduction of what I was seeing (see attached)
Файл не найден.Файл не найден.
In both cases I am expecting the letter variable to be assigned a value (A=1000, B=2000), and the block to return multiple values (Works=1,2, DoesNotWork=3,4). To my understanding both of these should work as they aren't affected by the order of operations.
Works: I would expect A to be assigned the value of '1000' then '1' to be returned as the first value in the system of values assigned to 'Works' with '2' being the other.
DoesNotWork: I am expecting that B will be assigned the value of '2000', then the line will return the system of values '3,4' which is assigned to the variable DoesNotWork.
The former is working as expected but the latter is clearly not assigning 'B', so my understanding must need a little tweaking. Can anyone offer some insight? Thanks!
#2 Опубликовано: 27.06.2022 14:48:20
I think in the second case, the content of the local Store is not copied to the global Store (B - local variable). You can try running the code under a debugger to experiment.
Russia ☭ forever, Viacheslav N. Mezentsev
#3 Опубликовано: 27.06.2022 15:58:48
Definitions made after line are only stored locally if the line symbol ist directly assigned to a variable, like done in DoesNotWorke2.
If you insert a function or an operation like + (or eval ...) before the line, the inner definitions are exposed to the canvas (made visible in the global context), e.g. DoesNotWork -> B.
If you assign line to variables as in the examples, the result is not calculated immediately. Rather it is calculated every time you call the variable, DoesnotWork2 in the following screenshot.
If you call it often (in loops, iterations ...) it is recommended to assign it once to the same or a new variable. Then the result of the little program or procedure is only calculated once.


If you insert a function or an operation like + (or eval ...) before the line, the inner definitions are exposed to the canvas (made visible in the global context), e.g. DoesNotWork -> B.
If you assign line to variables as in the examples, the result is not calculated immediately. Rather it is calculated every time you call the variable, DoesnotWork2 in the following screenshot.
If you call it often (in loops, iterations ...) it is recommended to assign it once to the same or a new variable. Then the result of the little program or procedure is only calculated once.
#4 Опубликовано: 27.06.2022 16:21:18
Oh neat! I can see that being useful in circumstances that are math intensive, like large loops or complex math. It allows for the removal of redundant overhead.
Thanks!
Thanks!
#5 Опубликовано: 27.06.2022 19:09:29
1 страниц (5 вхождений)
-
Новые сообщения
-
Нет новых сообщений