Open GlowingScrewdriver opened 1 week ago
A few more notes on the topic:
I can think of an alternative syntax to the macro call, one which would be much simpler to implement and read:
; In source program
,(include (header-name) (#:structs (struct-name1 struct-name2)))
The difference between this and the Guile implementation is that here, the keyword and value are specified as a pair and that pair is supplied as an argument, rather than they keyword and value being two separate arguments.
A keyword can be detected by the keyword?
Guile Scheme procedure, like this:
(keyword? #:key-name) ; result: #t
Consider the following Python function:
By design, either
functions
orstructs
can be unspecified (i.e.None
). At present, the only way to specifystructs
in a macro call while leavingfunctions
empty is the following:This could be made much more elegant with the use of keyword arguments. Consider the following procedure definition, mimicking the macro, in Guile Scheme:
This scheme procedure can be called as follows:
The most obvious benefit offered by keyword arguments in this case is that the empty list
()
needn't be passed as a parameter; thefunctions
parameter can simply be omitted. It is also important to note that while many members of the Scheme family offer keyword parameters, it is not part of the Scheme spec.Adopting a similar pattern, the original macro call can be made to look like this: