Open rebcabin opened 1 year ago
Another alternative:
Integer-pedantic
with option 1 for explicitness and Integer
with option 2 for brevity.I'll implement option 2 (brevity) for now, then add option 3 later because option 3 implies option 1 (explicitness)
I think we will implement Dimension as a dedicated ttype, similar to Pointer. So Integer will be just (Integer :kind 4)
. I would not do default kinds. In ASDL, some members have ?
, then they are optional, but when they do not have ?
, then they should always be present, so that the backend can simply count on it, instead of always querying if it is present and then using some default.
just to be clear, this discussion pertains only to syntax sugar. The "full-form" always has all info spelled out in a hash map.
On Thu, Apr 13, 2023 at 12:35 PM Ondřej Čertík @.***> wrote:
I think we will implement Dimension as a dedicated ttype, similar to Pointer. So Integer will be just (Integer :kind 4). I would not do default kinds. In ASDL, some members have ?, then they are optional, but when they do not have ?, then they should always be present, so that the backend can simply count on it, instead of always querying if it is present and then using some default.
— Reply to this email directly, view it on GitHub https://github.com/rebcabin/masr/issues/3#issuecomment-1507511482, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSRR24Q2WUI6D6TN3EKC3XBBIPLANCNFSM6AAAAAAW5IEBO4 . You are receiving this because you authored the thread.Message ID: @.***>
An example of a fully explicit ttype entity for
Integer
, is, say(Integer :kind 4, :dimensions [])
which produces
This latter is the 'ground truth', fully explicit hash-map that specifies all details explicitly.
This issue concerns the syntax-sugar constructor functions.
This Issue requests a preference for defaulting. Clojure only allows optional keyword arguments in functions. Absent keyword arguments in a call have value
nil
. This issues boils down to interpretingnil
in the syntax-sugar functionInteger
, that is, what does(Integer)
mean?
Alternatives:
Missing keyword arguments produce non-conforming specs, i.e., errors.
(Integer)
,(Integer :kind 4)
, and(Integer :dimensions [6, 42])
would be errors. Upside: explicitness. Downside: verbosity. Every valid call ofInteger
, say, is as long as(Integer :kind 4, :dimensions [])
.Missing keyword arguments are defaulted to
:kind 4
and:dimensions []
, so that(Integer)
,(Integer :kind 4)
, and(Integer :dimensions [])
all mean exactly(Integer :kind 4, :dimensions [])
. Upside: brevity. Downside: missing keywords are defaulted, so that a naive mistake like(Integer 'foobar [42 45 "foo"])
means exactly
(Integer :kind 4, :dimensions [])
Which alternative do you prefer? If neither, do you have a better proposal?