Hi, no one responded, so I had to figure this out myself. ;-)
My original definition of LIST was obviously flawed:
(syntax LIST (lambda (node compiler)
`[OrderedCollection withAll: ,@[node copyFrom: '1]]))
But this works as intended:
(syntax LIST (lambda (node compiler)
(let ((o [OrderedCollection new]) (i '1))
(while [i < [node size]]
[o add: [[node at: i] _eval]]
(set i [i + '1]))
`'(,@o))))
Hooray to #_eval - that made my day. Please let me know if it can be
optimised. ;-)
Best, Michael Am 05.01.2009 um 16:18 schrieb Michael Haupt:
Dear list,
having solved the trouble with shared libraries, I wrote some
"constructor" functions in Jolt to be able to build muy objects more
conveniently (i.e., avoiding the talkative keyword message syntax).
They look like this, for example:
(TYPE '23)
(assuming that TYPE is some type parameterised with a number) with
this implementation:
(syntax TYPE (lambda (node compiler) `[MyType with: ,[node at: '1]]))
This works fine unless I want to build a list of such "tagged type
constructions". What I would like to have is a LIST syntax definition
that accepts an arbitrary number of type constructor applications and
effectively returns an AST with all the expanded type constructions.
(LIST (TYPE '23) (TYPE '42))
Another usage example: (ANOTHER-TYPE (LIST (TYPE '23) (TYPE '42)))
My initial thought was that quasiquotation would help. I've been
experimenting like mad but could not come up with a solution. Here's
the (non-working) quasiquotation thing:
(syntax LIST (lambda (node compiler)
`[OrderedCollection withAll: ,@[node copyFrom: '1]]))
The trouble seems to be that ,@ expands all collection items in place,
instead of providing a collection again. #withAll:, however, obviously
expects a collection.
How should the syntax definition look?
Best,
Michael
--
Dr.-Ing. Michael Haupt [email protected]
Software Architecture Group Phone: ++49 (0) 331-5509-542
Hasso Plattner Institute for Fax: ++49 (0) 331-5509-229
Software Systems Engineering http://www.hpi.uni-potsdam.de/swa/
Prof.-Dr.-Helmert-Str. 2-3, D-14482 Potsdam, Germany
Hasso-Plattner-Institut für Softwaresystemtechnik GmbH, Potsdam
Amtsgericht Potsdam, HRB 12184
Geschäftsführung: Prof. Dr. Christoph Meinel
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc
-- Dr.-Ing. Michael Haupt [email protected] Software Architecture Group Phone: ++49 (0) 331-5509-542 Hasso Plattner Institute for Fax: ++49 (0) 331-5509-229 Software Systems Engineering http://www.hpi.uni-potsdam.de/swa/ Prof.-Dr.-Helmert-Str. 2-3, D-14482 Potsdam, Germany Hasso-Plattner-Institut für Softwaresystemtechnik GmbH, Potsdam Amtsgericht Potsdam, HRB 12184 Geschäftsführung: Prof. Dr. Christoph Meinel
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ fonc mailing list [email protected] http://vpri.org/mailman/listinfo/fonc
