Lartu / ldpl

COBOL-like programming language that compiles to C++. With serious dinosaurs with neckties and briefcases 🦕💼
https://www.ldpl-lang.org/
Apache License 2.0
158 stars 24 forks source link

Support for environment variables #92

Closed xvxx closed 5 years ago

xvxx commented 5 years ago

I don't think there's a way to get ENV variables in LDPL currently, right?

If not, they could either be pre-set like argv and argc, or there could be a new statement like STORE ENV AT "PATH" IN $path to do a lookup.

xvxx commented 5 years ago

Okay, you can do it this way:

$ cat env.ldpl
DATA:
$name is text
PROCEDURE:
execute "echo $NAME" and store output in $name
display "Your name is: " $name
$ ./env-bin
Your name is:
$ env NAME=Bobby ./env-bin
Your name is: Bobby

Maybe that's good enough? It's nice to keep the language small.

Lartu commented 5 years ago

The language is growing beyond what I've thought it would. It's still not a really usable language though. What I'm saying here is: if you'd like to add something to the language it's ok to do so.

In this particular case, I don't feel this is a necessary thing, as you can do that, but the main problem here is that environmental variables are different in Windows and in Unix/BSD, so making something that works for both would be kind of a chore.

xvxx commented 5 years ago

In this particular case, I don't feel this is a necessary thing, as you can do that, but the main problem here is that environmental variables are different in Windows and in Unix/BSD, so making something that works for both would be kind of a chore.

Makes sense! I like this reasoning. :+1:

Lartu commented 5 years ago

Awesome! Thank you! I'll be closing this then.