-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decide on syntax for optional type declaration #30
Comments
I’ve run into this in other Lisps, too ... we explored it in LFE a while ago; more recently in a Go Lisp I’ve been playing with, I explored all sorts of possibilities: Ultimately, I think I’d go with the following (mostly to stay closer to Go): (type point struct
[X float64]
[Y float64])
(defn distance
[a *Point b *Point] float64
(math/Sqrt
(+ (math/Pow (- b.X a.X) 2)
(math/Pow (- b.Y a.Y) 2)))) This seems to be analogous to what you have proposed, namely staying close to the parent language: (struct Point
x ::Float64
y ::Float64)
(defn distance
[(a ::Point) (b ::Point)] ::Float64
(sqrt
(+ (^ (- b.x a.x) 2)
(^ (- b.y a.y) 2)))) Although, I might rather have the Lisp do the interleaving of the args/types for me? (defn distance
[a ::Point b ::Point] ::Float64
(sqrt
(+ (^ (- b.x a.x) 2)
(^ (- b.y a.y) 2)))) |
worth a discussion. there are lots of ways to do this including the racket and clojure (core.typing) ways. As julia has parametric types with 'where' conditions, that would have to be thought through too. |
Since LispSyntax.jl is clojure-flavored, maybe syntax borrowed from defmethod would be a good analogy? https://clojuredocs.org/clojure.core/defmulti Or alternatively, perhaps it would be better to move away from the focus on clojure per se and focus on a lispy syntax which is as close as julia as possible. I think this is probably my preferred option if the mission of LispSyntax.jl is to be a lispy veneer over julia semantics. |
We'll need a type declaration syntax at least for method definitions.
I was thinking something like this
translating to
which leads to the question of parametric types and
where
. I'm not as sure about how to deal with those.The text was updated successfully, but these errors were encountered: