atlas-engineer / nclasses

A `define-class` macro for less boilerplate
Other
7 stars 2 forks source link

Flatted/inline slots #19

Closed aartaka closed 1 year ago

aartaka commented 1 year ago

So we mostly stick to the overall structure of defclass with our define-class, which is cool. but then there's an extra layer of parentheses to slot definitions we have:

(define-class name ()
  ((slot-a 5)
   (slot-b 8)))

While this is consistent with historic form, it would be cool to drop this extra layer. Several problems with it:

I'm extremely uncertain about this, but if we make it deterministic enough, then why not have it?

Ambrevar commented 1 year ago

Another point:

aartaka commented 1 year ago
  • How to you distinguish options from slots? Could check if first element is a keyword or a symbol, but we should see what the standard allows here.

Keyword checking is safe, I guess. defclass doc says:

Slot-name--a symbol. The slot-name argument is a symbol that is syntactically valid for use as a variable name. 

And then, keywords cannot be variables, at least. Spinneret uses keywords as macro names, and you can defun a keyword function, which is not cool, but slot name... I'm not sure—keywords are not valid boundp variable names, at least (҂⌣̀_⌣́)

aartaka commented 1 year ago

Uh oh, that's bad. CCL and ECL both allow keywords as slot names.

aartaka commented 1 year ago

Closing as not-implementable-reliably then.