This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Thanks for the explanation Helmut. On 9 April 2012 07:25, Per Bothner <per@bothner.com> wrote: > Yes. ÂCommon Lisp uses colon for a package prefix of a compound symbol, > and it's unclear how that should interact with colon notation or other > short-hands. ÂI suggest using the procedures invoke and invoke-static, > rather > than using colon notation. ÂWe might consider some kind of abbreviated > syntax for Common Lisp, but let's not worry about that for now. The reason I feel I need this is in a definition for CAR. The Scheme version is currently: (define (car x) (if (eq? x '()) x ((as <pair> x):getCar))) I should be able to simulate that by creating a new lexical scope for DECLARE: (defun car (x) (if (null x) nil (let () (declare (pair x)) (invoke x 'getCar)))) This seems quite nasty, it's worse because DECLARE currently doesn't work properly in this case. It sets the type of declaration X to PAIR before runtime IIUC, so this version of CAR rejects inputs like '() because they're not of type PAIR. Clearly the simple-minded approach in Lisp2Compilation#processTypeDeclArgs of: decl = this.lexical.get(var); decl.setType(this.exp2Type((Pair) typeList)); decl.setFlag(Declaration.TYPE_SPECIFIED); is not correct. I get the feeling that I'm over-complicating the issue, but it seems like I need to create "ghost aliases" for each new lexical scope for use by DECLARE, so that it can reliably modify the extent of a variable. I'm sorry for making up jargon, by "ghost alias", I mean fudging Compilation#current_scope so that it holds alias declarations from further up the static chain. This seems expensive, horrible, simple-minded, etc, but I really don't know how else to get things like this working: (defun test (x) (if #t x (let () (declare (integer x)) x))) (test 10.4) ; Value: 10.4 The current behavior is (test 10.4) ; Type error, expecting INTEGER, found DFLONUM. I also found that scoping was quite broken with my previous patch, calling super.rewrite_body was a bad idea, I was getting results like: (let ((x 10)) (display x) (let ((x 20)) (display x)) (display x)) ;Value: 10 20 20 For reasons I can only attribute to magic. Avoiding the calls to super by completely overriding the rewrite_body fixed this, but my soul will be forever damned by the refactoring community, since I had to change a few private methods to protected ones in order to shoehorn the change in. Code attached. Charles.
Attachment:
declare.diff
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |