emdash / udlang

A practical, functional language for stream processing.
GNU Lesser General Public License v3.0
1 stars 0 forks source link

Do we need language support for certain changing quantities? #15

Open emdash opened 3 years ago

emdash commented 3 years ago

To be clear, uDLang execution should in general be deterministic, and always produce the same output for the given input.

This is a problem when we might want it to change.

Couple of approaches to handle it:

Language level support for PRNGs: treat them as at least iterable, and hide the state in the loop iteration.

The bigger problem is unique IDS. One idea is to have a Atom<T> type in the language, which would be a unique integer ID that is opaque. The issue here is that, whether generated by a counter, or a PRNG, we don't want to allow the script to observe the value, since it would violate some pretty big assumptions in the language. But then, how can we actually use it? One strategy would be to treat Atom<T> as an "output only" value. The only thing we would be able to do within uDLang is compare two atoms for equality, and use them somewhere in an out statement expression.

This would force you to use Token<T> in your output declaration, and you would have to rely on the implementation to serialize. Explicitly, you can't do anything with these that might leak the internal value, in particular, you can't convert it to a string that would be visible in the code.

Another idea is to have a resource declaration statement, so we can shove whatever nasty hacks we want to use under the rug.