You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Clojure, a function defined with defn can take multiple argument lists to achieve multi-arity. In Fennel, this achieved with simply passing nil to unneeded args. If an arg is strictly needed, lambda is used over fn:
Different ways to achieve the same end goal, mostly because Fennel is based on Lua which has its own limitations compared to Java
In Aniseed however, defn only compiles to the named function desired defined with fn, which is then added to the current module. Example:
(defnfunc [arg1arg2arg3?] (printarg1arg2arg3?))
(func1) ; --> falsely prints '1 nil nil' instead of a runtime error; expansion
["ANISEED_DELETE_ME"
(fnfunc [arg1arg2arg3?] (printarg1arg2arg3?))
(tset*module*"test"test)]
arg3? cannot be nil checked and return a runtime error as defn always compiles to fn. This seems incongruent with what this macro is attempting to mimic
The text was updated successfully, but these errors were encountered:
katawful
changed the title
Lambda checked defn function?
Lambda function defined with defn?
Jun 5, 2022
Hmm, this would be a breaking change for all users I think, anyone who allowed nils or optional args would suddenly have this code break on update.
If I ignored backwards compatibility I guess defn would need to wrap your functions you provide to switch to the one with the correct arity AND use lambda instead for arity checking. Maybe this could be some sort of option you can switch off / have to opt into.
Maybe instead I could define defns/defn!/defun/deflambda that has this new, more locked down, but multi arity supporting idea.
If it would lead to breakages then a new macro would be far more ideal yeah. deflambda seems like the most reasonable name to me, as defn already contains fn from fennel's keywords
In Clojure, a function defined with
defn
can take multiple argument lists to achieve multi-arity. In Fennel, this achieved with simply passing nil to unneeded args. If an arg is strictly needed,lambda
is used overfn
:Different ways to achieve the same end goal, mostly because Fennel is based on Lua which has its own limitations compared to Java
In Aniseed however,
defn
only compiles to the named function desired defined withfn
, which is then added to the current module. Example:arg3?
cannot be nil checked and return a runtime error as defn always compiles to fn. This seems incongruent with what this macro is attempting to mimicThe text was updated successfully, but these errors were encountered: