I’m thinking about adding support for keyword arguments in the next release of uLisp. So, for example, instead of having to remember that the command to define an I/O pin as INPUT_PULLUP is:
(pinmode pin 2)
you will be able to write:
(pinmode pin :input-pullup)
This will be especially useful with the Arduino function analogreference which will be supported in the next version of uLisp, as some platforms support multiple options. For, example, on the Arduino Mega 2560 you will be able to specify any of the options:
(analogreference :default)
(analogreference :internal1v1)
(analogreference :internal2v56)
(analogreference :external)
The keyword parameters will automatically pick up the values they represent from the appropriate Arduino core, so for example it’s not a problem if the number representing :input-pullup is different on two different platforms.
The simplest way to implement the keyword parameters will be to include them in the table of built-in symbols, called lookup_table[] in the uLisp source. However, there’s a problem: because the keywords are platform-specific, and there’s a different number of keywords on each platform, they will have to go at the end of the table with #defines to select the keywords for each platform. This will slightly complicate the procedure for Adding your own functions, which currently doesn’t require you to renumber the existing function entries in the table when you add new ones.
Does this sound like a useful feature? Can you think of any other uses for these keyword parameters? Any suggestions about the implementation?