Remix.run Logo
drnick1 4 hours ago

Small programming language with everything passed by value? You reinvented C?

jcparkyn 4 hours ago | parent [-]

Not everything in C is pass-by-value. Sure, you can argue that a pointer itself is passed by value, but the data it points to is definitely not.

globalnode 3 hours ago | parent [-]

cool project. can you take the address of a variable in some way? i.e. implement your own pointers if its really really needed?

jcparkyn 2 hours ago | parent [-]

> can you take the address of a variable in some way?

I intentionally didn't add this, mostly because I wanted to explore how far you can get without it (and keep the language simple). Having a "real" pointer as a first class type wouldn't work though, since it would break a lot of the assumptions I use for optimizations.

I did think about two different versions of this but didn't end up adding either:

- Something like `inout` parameters in Swift, which aren't first class pointers. This is really just an alternate syntax for returning multiple values. - A "ref" type, which is essentially a mutable container for an arbitrary value. Passing the container around would share a reference to the same mutable value. This still wouldn't allow modifying values "outside" of the container though.