[gambit-list] Compiling Meroon objects and initializers

Mikael mikael.rcv at gmail.com
Sat Jul 9 09:11:03 EDT 2011


Well you should still somehow get a ,be to the underlying gambit repl to
check. Anyhow probably what's happening is that

(define-class my-object Object
  ((= object-id :initializer get-next-global-id)))

is interpreted by Gambit as three expressions in each other, and it starts
evaluating the inner-most, so what you see down there is a complaint that
object-id and :initializer are unbound - which is projected as the value
#!unbound - which is indeed not a number.

This in turn probably happens because you didn't include Meroon ['s sources]
into your Scheme environment (in this case: your sourcecode file) prior to
using Meroon functionality (i.e. define-class etc.) .

Brgds

2011/7/9 Roger Wilson <misterrogerwilson at gmail.com>

> Hi,
>
> Thanks for the help, I'll try and clarify.  I'm actually using Swank rather
> than a REPL.
>
> If I run my app, connect to it with Slime and evaluate the code below using
> 'slime-eval-region' then I can create instances of the my-object class using
> (instantiate my-object), and each object has a unique object-id.  I was
> happy with that during the early stage of development.  Now I'm trying to
> speed things up so I've put the code below in a scm file, I generate C code
> with 'gsc -link my_file.scm' and compile and link it in with my (OS X) app.
> However when the Gambit setup function is called in my app I get the
> error.....
>
> *** ERROR IN | object| -- (Argument 1) NUMBER expected
> (= #!unbound #!unbound 'get-next-global-id)
>
> How can I convince Meroon to run the 'get-next-global-id ' function to
> generate an object-id each time I instantiate an object in the same way as
> when I was developing interactively?
>
> Roger.
>
>
>
> On Sat, Jul 9, 2011 at 9:07 AM, Mikael <mikael.rcv at gmail.com> wrote:
>
>> Hi,
>>
>> As for the error you encountered, can you please do ,be in the REPL to see
>> exactly what it is that failed.
>>
>> Regarding how to make it work with a compiled file, can you please clarify
>> what you mean by making it to work with a compiled file - i.e., what is it
>> you are trying to achieve, and what part of it is it that you don't get to
>> work currently?
>>
>> Brgds,
>> Mikael
>>
>> 2011/7/9 Roger Wilson <misterrogerwilson at gmail.com>
>>
>>> Hi,
>>>
>>> I have a basic Scheme question.
>>>
>>> The following works as intended from my Swank REPL.  How do I make it
>>> work with a compiled file?  I'm trying to create a Meroon object that has an
>>> automatically created unique id each time one is created.
>>>
>>> (define *global-id* 0)
>>> (define (get-next-global-id)
>>>     (let ((current-global-id *global-id*))
>>>          (set! *global-id* (+ *global-id* 1))
>>>          current-global-id))
>>>
>>> (define-class my-object Object
>>>   ((= object-id :initializer get-next-global-id)))
>>>
>>>
>>> When the Gambit setup function runs I get the error....
>>>
>>> *** ERROR IN | object| -- (Argument 1) NUMBER expected
>>> (= #!unbound #!unbound 'get-next-global-id)
>>>
>>>
>>> Roger.
>>> _______________________________________________
>>> Gambit-list mailing list
>>> Gambit-list at iro.umontreal.ca
>>> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20110709/3477bc44/attachment.htm>


More information about the Gambit-list mailing list