Opened 14 years ago

Closed 14 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 Changed 14 years ago by felix winkelmann

Added ##sys#parse-keyword-argument-list in 8f79e95e7a50a216f1c46e472263d566ef06de66 (experimental).

comment:2 in reply to:  1 Changed 14 years ago by felix winkelmann

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 14 years ago by felix winkelmann

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.