Local variables in functions (Calliope? Or NEPO in general?)

120 views
Skip to first unread message

Lars Pelz

unread,
Mar 6, 2017, 4:09:47 PM3/6/17
to Open Roberta
Hi Roberta Roboter!

I'm struggling with NEPO's functions. Somehow, I can't find out how to define local variables. That made me use global variables instead, which I find quite annoying. Am I missing something here or am I supposed to use parameters as local variables? Perhaps that's something that applies to NEPO in general...
Thanks in advance for your reply!

Greetings - Lars Pelz

That's how I'm doing stuff now... but I'd rather like to use the return statement and a local variable as counter.
no-local-variable-demo.xml
Auto Generated Inline Image 1

Kostadin Cvejoski

unread,
Mar 7, 2017, 5:26:48 AM3/7/17
to Open Roberta
Hi,

In NEPO we do not support currently local variables. Instead you can use function parameters. 
You can also use a method with return, however in the current version of the lab there is bug in the simulation when you use custom functions with return. This is already fixed for the next version

Best
Kostadin 

Lars Pelz

unread,
Mar 7, 2017, 5:51:24 AM3/7/17
to Open Roberta
Hi Kostadin!

Thanks for your help! I see... well, should I do it like this, then? Let's hope the dummy parameter doesn't get people confused.
Ah, by the way... Why is the return notch labelled "get" at the end of the function?

Cheers, Lars
Auto Generated Inline Image 1

Kostadin Cvejoski

unread,
Mar 8, 2017, 7:24:14 AM3/8/17
to Open Roberta
Hi Lars,

Yes, it is a way to do it. However, I think is maybe less confusing to use a global variable presses.

The "get" label in the return function is a bug in the translation. We will fix that

Best
Kostadin

Lars Pelz

unread,
Mar 9, 2017, 9:20:49 AM3/9/17
to Open Roberta
Hey Kostadin!

Thanks for putting the translation fix in the queue ;)
I'm still reluctant to use global variables in functions since this may introduce heavy side effects if the variables aren't named properly (like i, j, etc). And let's face it: The concept of scope was introduced to programming languages in the 60ies. I'd really like to teach kids nice and clean code and not something that's a no-go in contemporary programming. So as it is, I'll just work my way around this bit and see what I can do without local variables. I'd be happy to figure out myself how to get a few features into Open Roberta, but as of now, I'm still busy with creating materials.

Greetings - Lars
Reply all
Reply to author
Forward
0 new messages