Hey, Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Thanks!
Afficher les réponses par date
oh wait, this is in lib/_nonstd.scm, I guess this explains why documentation has been so hard to come by. can anyone explain how:
(define-prim (##define-type-expand ...) ... in lib/_nostd.scm ) works ?
it seems like an _awful_ lot of code to setup a few macros ... so there must be something magical (optimizations) going on that I'm not aware of.
Thanks!
On Tue, May 26, 2009 at 3:19 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
Hey, Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Thanks!
sorry for spamming, here's actually what I really want to do (and maybe there's an easier solution than figuring out how define-type works) I have:
(define-type shape ...) (define (shape-draw shape) ...)
(define square (make-shape ...)) (define circle (make-shape ...))
Now, I want (square 'draw) to call (shape-draw square) and (circle 'draw) to call (shape-draw circle)
how do I make this link?
thanks!
On Tue, May 26, 2009 at 3:43 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
oh wait, this is in lib/_nonstd.scm, I guess this explains why documentation has been so hard to come by. can anyone explain how:
(define-prim (##define-type-expand ...) ... in lib/_nostd.scm ) works ?
it seems like an _awful_ lot of code to setup a few macros ... so there must be something magical (optimizations) going on that I'm not aware of.
Thanks!
On Tue, May 26, 2009 at 3:19 PM, lowly coder <lowlycoder@huoyanjinjing.com
wrote:
Hey, Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Thanks!
I was searching for the answer to this question recently and found this information in the list archives:
https://webmail.iro.umontreal.ca/pipermail/gambit-list/attachments/20090226/...
- Jamie
----- Original Message ----- From: lowly coder lowlycoder@huoyanjinjing.com Date: Tuesday, May 26, 2009 4:19 pm Subject: [gambit-list] define-type To: Gambit List gambit-list@iro.umontreal.ca
Hey, Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Thanks!
Thanks! gsi Gambit v4.4.2
(##structure 1 2 3)
Bus error
this seems to disagree with the implication that ##structure == vector with two extra fields, one for procedure? one for the object tag
can anyone enlighten me on this?
On Tue, May 26, 2009 at 4:42 PM, Jamie Briggs jamie.briggs@shaw.ca wrote:
I was searching for the answer to this question recently and found this information in the list archives:
https://webmail.iro.umontreal.ca/pipermail/gambit-list/attachments/20090226/...
- Jamie
----- Original Message ----- From: lowly coder lowlycoder@huoyanjinjing.com Date: Tuesday, May 26, 2009 4:19 pm Subject: [gambit-list] define-type To: Gambit List gambit-list@iro.umontreal.ca
Hey, Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Thanks!
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
lowly coder wrote:
Hey,
Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Hi there!
I've put some of Marc's undergrad notes related to define-type in the gambit-c wiki a while ago:
http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Define-type
Hope it can help!
David
Cool, thanks! Another quesiton on define-type -- is there anyway to get back an unique identifier for the type?
i.e. if I have:
(define f1 (make-foo ..)) (define f2 (make-foo ...))
(define b1 (make-bar ..)))
I want something so that
(equal? (type f1) (type f2)) and (not (equal? (type f1) (type b1)))
the idea is then, I can do dispatching on types i.e.
(define (draw object) ((lookup-in-hash-table (type object)) object))
Thanks!
On Wed, May 27, 2009 at 5:14 AM, David St-Hilaire <sthilaid@iro.umontreal.ca
wrote:
lowly coder wrote:
Hey,
Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Hi there!
I've put some of Marc's undergrad notes related to define-type in the gambit-c wiki a while ago:
http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Define-type
Hope it can help!
David
It appears ##structure-type is what I want. Anyone smarter than me want to either:
(1) confirm this is the right answer or (2) tell me why using ##structure-type for this purpose is a bad idea?
Thanks!
On Wed, May 27, 2009 at 1:44 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
Cool, thanks! Another quesiton on define-type -- is there anyway to get back an unique identifier for the type?
i.e. if I have:
(define f1 (make-foo ..)) (define f2 (make-foo ...))
(define b1 (make-bar ..)))
I want something so that
(equal? (type f1) (type f2)) and (not (equal? (type f1) (type b1)))
the idea is then, I can do dispatching on types i.e.
(define (draw object) ((lookup-in-hash-table (type object)) object))
Thanks!
On Wed, May 27, 2009 at 5:14 AM, David St-Hilaire < sthilaid@iro.umontreal.ca> wrote:
lowly coder wrote:
Hey,
Where is define-type documented? I can't find it in r5rs or in the gambit documentation (though it is briefly mentioned in a tour of scheme through gambit). define-type is really cool and I'm starting to run against my limited knowledge of it.
Hi there!
I've put some of Marc's undergrad notes related to define-type in the gambit-c wiki a while ago:
http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Define-type
Hope it can help!
David
lowly coder wrote:
It appears ##structure-type is what I want.
Anyone smarter than me want to either:
(1) confirm this is the right answer or (2) tell me why using ##structure-type for this purpose is a bad idea?
1,2: From my point of view, ## calls should be avoided if possible. I would suggest to dispatch using a cond form like:
(cond ((foo? x) ...) ((bar? x) ...))
This gets annoying for multiple dispatch, but then again, you're probably much better to use an object system for gambit! There are a couple of them on the dumping ground, ranging from very simple ones to more complete and elaborate ones.
Good luck ;)
David