I'm a bit tired today, so the post will be short.
In Scheme, it is conventional for procedures returning booleans to have names ending in
even?), and for procedures which mutate their arguments to have names ending in
reverse!). This convention has also been adopted by other languages, such as Ruby, Clojure and Elixir.
I like this convention, and I've been thinking of using it in Fenius too. The problem is that
! are currently operator characters.
? does not pose much of a problem: I don't use it for anything right now.
!, however, is a bit of a problem: it is part of the
!= (not-equals) operator. So if you write
a!=b, it would be ambiguous whether the
! should be interpreted as part of an identifier
a!, or as part of the operator
!=. So my options are:
! exclusively as an identifier character. This would mean changing
!= to something else, like
/= (as in Haskell or Common Lisp) or
<> (as in Pascal) or
~= (as in Lua). But
!= is familiar to a lot of people, and I'm not sure it's a good idea to change it.
! exclusively as an operator character. Then the
! convention is gone and has to be replaced by something else. Currently, when you import a Scheme module into Fenius, the names are converted such that names ending in
? are prefixed with
isEven), and names ending in
! are prefixed with
doReverse). [Update: I will be switching to
snake_case rather than
! as an identifier character if it follows with other identifier characters, but as an operator character when not preceded by other identifier characters (in much the same way as digits are considered part of an identifier if they immediately follow other identifier characters, but as numbers if not). So you would have to write
a != b with spaces instead. I don't like this very much.
What do you think? Which of these you like best? Do you have other ideas? Feel free to comment.
In other news, I started to make available a precompiled Fenius binary (amd64 Linux), which you can try out without having to install Chez Scheme first. You should be aware that the interpreter is very brittle at this stage, and most error messages are in terms of the underlying implementation rather than something meaningful for the end user, so use it at your own peril. But it does print stack traces in terms of the Fenius code, so it's not all hopeless.
Copyright © 2010-2021 Vítor De Araújo
O conteúdo deste blog, a menos que de outra forma especificado, pode ser utilizado segundo os termos da licença Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.
Powered by Blognir.