Opened 15 years ago
Closed 15 years ago
#221 closed enhancement (wontfix)
defstruct could use compiler-syntax to speed up instance creation
Reported by: | felix winkelmann | Owned by: | felix winkelmann |
---|---|---|---|
Priority: | not urgent at all | Milestone: | |
Component: | core libraries | Version: | |
Keywords: | keywords eval compiler-syntax | Cc: | |
Estimated difficulty: |
Description
By defining a compiler-macro on the constructor, keyword arguments can be pre-parsed and the constructor call be replaced by a direct structure value construction. Since this is applicable to various procedures, a general library procedure might be handy:
(unit eval
)
(parse-keyword-arguments ARGLIST KEYS+DEFAULTS K) -> FORM
where K is a procedure TMPVARS -> BODY
that returns a body. FORM
is then a let*
form binding temporaries to keep the original evaluation order of the arguments. In case of an invalid keyword argument list (computed keyword, missing keyword argument, non-keyword in keyword position, etc.) parse-keyword-arguments
returns #f
.
Change History (3)
comment:1 follow-up: 2 Changed 15 years ago by
comment:2 Changed 15 years ago by
Replying to felix:
Added
##sys#parse-keyword-argument-list
in 8f79e95e7a50a216f1c46e472263d566ef06de66 (experimental).
... and removed it again. It is better placed inside the defstruct code or into a separate extension.
comment:3 Changed 15 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
No easy implementation: defstruct
has to expand into a compiler-syntax definition that must pass a list of keywords and default arguments, but those arguments are quoted in the definition and will lose renaming information.
Currently not worth the trouble.
Added
##sys#parse-keyword-argument-list
in 8f79e95e7a50a216f1c46e472263d566ef06de66 (experimental).