Simplifying and unifying syntax
porky11 opened this issue · comments
In the thread on google you thought it would be more uniform if linkage was not written inside the declaration of definitions.
(def x (… linkage …))
could be written as (def x linkage (… …))
then anonymous functions would look more similar to function declarations.
What about this change?
Some other idea I had is adding macros, which expand to def forms (for example defn
, def-macro
, def-struct
and def-var
) to be more uniform with other macro-def-forms (like def-enum
, def-variant
, def-concept
, def-concept-macro
, etc.).
(it would also make sence to drop the def-forms entirely maybe)
Using def-
forms has some benefits: no unneccessary brackets, writing macros, which work for multiple def-forms, is easier, you see immideately, what is defined. friendlier to lispers.
maybe also all macro-def-froms should take a linkage (like def-concept
and def-recursive-macro
but in these cases, it probably won't be useful, not to be extern)
After thinking about this some more, the current syntax will remain as-is, for two reasons.
- Moving linkage specification to the top form implies that all
def
s have the same acceptable set of linkage values, but that is not the case. - Switching to
defn
etc. will lessen consistency between the named and anonymous forms for both functions and structs. E.g., either there will bedefn
for named functions whilefn
continues to be used for anonymous functions, ordefn
will be used in both cases but be even more different than the two currentfn
forms. While that doesn't of itself mean that macros and variables couldn't be converted todef-macro
anddef-var
, there is the potential in both of those cases for anonymous forms to be implemented, so going to the trouble doesn't appear to be worthwhile.