chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Bugs in documentation and Mac OS X 10.6.8 executable


From: Mario Domenech Goulart
Subject: Re: [Chicken-users] Bugs in documentation and Mac OS X 10.6.8 executable generation broken
Date: Mon, 05 Dec 2011 12:14:16 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

On Mon, 5 Dec 2011 11:03:44 -0600 Watson Ladd <address@hidden> wrote:

> On Mon, Dec 5, 2011 at 9:22 AM, Mario Domenech Goulart
> <address@hidden> wrote:
>>
>> On Mon, 5 Dec 2011 08:52:06 -0600 Watson Ladd <address@hidden> wrote:
>>
>>> csi has it for making scripts run. This could simply be a case of me
>>> assuming that the interpreter and compiler took similar options, which
>>> is likely. So now i see what happens: csc takes the -ss switch and
>>> interprets it as -s, which causes the result.
>>>
>>> So what is the correct way to compile an SRFI-22 compliant script to
>>> an executable?
>>
>> I'm not sure I understand your question.  Usually it's just a matter of
>>
>>    $ csc your-program.scm
>>
>> A binary executable file called `your-program' will be generated.
>
> So that works: I get an executable. But the executable does nothing
> but take up time when run. I've got a SRFI-22 compliant script: that
> is I want the executable to evaluate (main argslist) where argslist is
> a list containing strings corresponding to the entries of the argv
> vector. The interpreter has a flag for this: the compiler doesn't seem
> to. Do I need to put in a toplevel expression, and if so, which one?

Maybe you are assuming a `main' procedure would be automatically called
when you run your compiled code?  If so, that's not going to happen, and
AFAIK, there's no compiler option to do that.  You can just explicitly
call your `main' procedure and run your scripts with csi -s" instead of
"csi -ss".  The compiled code would just work this way.

Here's a very simple example:

    $ cat foo.scm
    #!/bin/sh
    #| -*- scheme -*-
    exec csi -s $0 "$@"
    |#
    
    (define (main)
      (display 'foo)
      (newline))
    
    (main)
    
    $ ./foo.scm
    foo
    
    $ csc foo.scm
    $ ./foo
    foo


Notice that there's nothing special about `main' in this case.  It can
be any valid identifier.  AFAIK, `main' is only relevant when you want
to use your scripts with the -ss option to csi (not csc).

Regarding scripts, I usually use the first tip from
http://wiki.call-cc.org/writing%20portable%20scripts (as shown in the
example above).


> Thanks for taking the time to answer my questions: I'm reasonably
> experienced with scheme, but recently needed to turn some scheme into
> something that can run on systems with only a C compiler.

You are welcome.


Best wishes.
Mario
-- 
http://parenteses.org/mario



reply via email to

[Prev in Thread] Current Thread [Next in Thread]