I've just started trying this out. At the moment this is more a proof of concept than anything else. All the same, I'll give it a shot.
Today I spent a great deal of time working on quietude (you can find it on my github!). One mildly frustrating aspect of C that I'm still wrapping my head around is the way parameters and return values are treated in functions. As far as I can tell, function parameters never leave the function scope. For instance, in the case of the following:
x++;
return;
}
the caller of f()
never gets access to the incremented
argument. This is a little confusing to me but it makes sense. It's
consistent with the way C sees the world. This is where pointers come in!
The documentation generator I use (i.e., doxygen
) has an
optional tag for unction parameters called in
and
out
. As far as I can tell, the way this is thought of is that
certain parameters (namely pointers) can have their contents altered. The
specific address it points to will naturally never change, but the
information stored at the address can be. In this way a parameter can
be thought of as an out
parameter if the information stored at
the address changes, even if the address itself never changes.
Despite how irritating this can be, it's a really elegant and pure approach
to it all. The only way a function can ever alter anything in the line in
which it's called is if a variable is defined as the return value of the
function. When you give a function a parameter, you have absolute certainty
that the specific variables will not be altered. And then in such cases as
you want a parameter to be altered, you just supply the pointer. It's cool!
In other news, I nabbed the neocities CLI. It works like a charm (even if
the github repo that arch uses is dreadfully outdated and I had to spend
more time than I can excuse tracking down its current version. (for those in
a similar boat, get the package from ruby from your package manager and then
run gem install ruby
. don't forget to update your
PATH
!)). It's dreadfully elegant and there's even a post on the
main neocities site that helps one set up a git hook that automatically
pushes updates to neocities whenever git push
is called.
I think that'll be all for today. Bye <3