stedolan / malfunction

Malfunctional Programming
Other
336 stars 19 forks source link

Make adding primitives easier #22

Closed ziman closed 4 years ago

ziman commented 4 years ago

This patch:

Addresses #21.

stedolan commented 4 years ago

The code makes sense to me, but I'm not totally sure what this is for. The string length and string access primitives are already available as length.byte and load.byte, although the docs are pretty sparse.

Is this because you were using (global $String $get)? We could support that, but if possible I'd prefer to steer people towards load.byte, because that works in the interpreter too. Programs working in the interpreter is useful: if a malfunction program crashes, the interpreter can tell you exactly what went wrong. Also, sometimes buggy programs will happen to work by machine-specific coincidences, but the interpreter can catch those cases.

ziman commented 4 years ago

Oh, I see, thank you. This is just the kind of feedback I needed.

The reason I added these primitives was that I called various functions from the stdlib and they complained that their underlying primitives were missing — so I added them. I did not know that adding primitives like that would be a problem, and the convenience of having the whole stdlib available seemed very worthwhile to me.

However, I think I can hack up the things I've needed so far using just arrays and byte arrays myself, without the stdlib. Let's see how far that gets me.