public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Question about command-line-arguments and main method
@ 2013-02-04 18:15 Matthieu Vachon
  2013-02-04 20:59 ` Per Bothner
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Vachon @ 2013-02-04 18:15 UTC (permalink / raw)
  To: kawa

Hi,

I hit a small problem with the variable `command-line-arguments`. The
compiler is always complaining that this variable is not declared.

Here the module I used (named `test.scm`):

(module-name <org.kawa.warning>)

(if (eq? command-line-arguments '#())
    (format (current-output-port) "No command arguments provided~%")
    (format (current-output-port) "Command arguments: ~a~%"
command-line-arguments))

And here the output produced by the compiler when doing `java
kawa.repl -d obj -C test.scm`:

(compiling src/scheme/test.scm to org.kawa.warning)
src/scheme/test.scm:3:10: warning - no declaration seen for
command-line-arguments
src/scheme/test.scm:5:61: warning - no declaration seen for
command-line-arguments

Is it a problem with how I use the variable? Is it a bug in the
compiler? This is a problem because we plan to treat error as warning
using `--warn-as-error` and this prevents compilation of those units.

I would also like to know if it's possible to produce a `.class` that
has a static main method in it so it's possible to call directly (.i.e
`java org.kawa.main` for example)?

Thanks in advance :)

Regards,
Matt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about command-line-arguments and main method
  2013-02-04 18:15 Question about command-line-arguments and main method Matthieu Vachon
@ 2013-02-04 20:59 ` Per Bothner
  2013-02-04 21:27   ` Matthieu Vachon
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2013-02-04 20:59 UTC (permalink / raw)
  To: Matthieu Vachon; +Cc: kawa

On 02/04/2013 10:15 AM, Matthieu Vachon wrote:
> I hit a small problem with the variable `command-line-arguments`. The
> compiler is always complaining that this variable is not declared.

There are a number of solutions.

The simplest and best is to use the R6RS/R7RS command-line function.
See http://www.gnu.org/software/kawa/Processes.html

More generally, to shut up "no declaration seen" warnings you
can add a define-variable declaration:
     (define-variable command-line-arguments)

You can also nest the variable reference in a with-compile-options form:
    (with-compile-options warn-undefined-variable: #t EXPRESSION)
See http://www.gnu.org/software/kawa/Module-classes.html

I should probably fix command-line-arguments so it is always seen,
but given that the standards-based command-line function seems
preferable, it's a pretty low priority.

> Is it a problem with how I use the variable? Is it a bug in the
> compiler? This is a problem because we plan to treat error as warning
> using `--warn-as-error` and this prevents compilation of those units.

I certainly want to encourage this practice!

> I would also like to know if it's possible to produce a `.class` that
> has a static main method in it so it's possible to call directly (.i.e
> `java org.kawa.main` for example)?

You mean the --main Kawa flag?
See http://www.gnu.org/software/kawa/Compiling.html#Application-compilation

(If I come across as implying you should have read these answer in the 
manual,
that is not my intention.  It's a big language, and a big manual, and even
I don't remember it all.  All the same, if you have concrete suggestions for
how the documentation can be improved, that is always welcome.)
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about command-line-arguments and main method
  2013-02-04 20:59 ` Per Bothner
@ 2013-02-04 21:27   ` Matthieu Vachon
  2013-02-04 21:40     ` Per Bothner
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Vachon @ 2013-02-04 21:27 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

On Mon, Feb 4, 2013 at 3:58 PM, Per Bothner <per@bothner.com> wrote:
> On 02/04/2013 10:15 AM, Matthieu Vachon wrote:
>>
>> I hit a small problem with the variable `command-line-arguments`. The
>> compiler is always complaining that this variable is not declared.
>
>
> There are a number of solutions.
>
> The simplest and best is to use the R6RS/R7RS command-line function.
> See http://www.gnu.org/software/kawa/Processes.html

This seem promising, definitely the way to go.

>
> More generally, to shut up "no declaration seen" warnings you
> can add a define-variable declaration:
>     (define-variable command-line-arguments)

Since I don't like to wrap expression with a `with-compile-options`, I
will probably go with this option for now just to make the compiler
happy :)

>
> You can also nest the variable reference in a with-compile-options form:
>    (with-compile-options warn-undefined-variable: #t EXPRESSION)
> See http://www.gnu.org/software/kawa/Module-classes.html
>
> I should probably fix command-line-arguments so it is always seen,
> but given that the standards-based command-line function seems
> preferable, it's a pretty low priority.
>
>
>> Is it a problem with how I use the variable? Is it a bug in the
>> compiler? This is a problem because we plan to treat error as warning
>> using `--warn-as-error` and this prevents compilation of those units.
>
>
> I certainly want to encourage this practice!
>
>
>> I would also like to know if it's possible to produce a `.class` that
>> has a static main method in it so it's possible to call directly (.i.e
>> `java org.kawa.main` for example)?
>
>
> You mean the --main Kawa flag?
> See http://www.gnu.org/software/kawa/Compiling.html#Application-compilation
>

I did not express myself clearly on this one sorry. I meant exactly
this flag but on a per module basis. In fact, we currently have a
wrapper around the kawa compiler. The wrapper will parse the first
line of the file and if the first line starts with `##(main)`, our
wrapper will add the flag to the compiler.

But our wrapper use the Kawa internals. I'm upgrading from 1.7.90 to
1.13 and I had to update it because some changes happen since then :).
In fact, I'm trying to move away from our wrapper (using the `kawac`
ant task is my target).

So, I need a way to activate the --main flag on a per module basis. If
it does exist right now, I'm more then willing to implement it via a
new `module-compile-options` keyword. What do you think of such
option?

> (If I come across as implying you should have read these answer in the
> manual,
> that is not my intention.  It's a big language, and a big manual, and even
> I don't remember it all.  All the same, if you have concrete suggestions for
> how the documentation can be improved, that is always welcome.)

No problem at all, I did not perceive this from your message. Thanks
for your help.

> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about command-line-arguments and main method
  2013-02-04 21:27   ` Matthieu Vachon
@ 2013-02-04 21:40     ` Per Bothner
  2013-02-04 22:04       ` Matthieu Vachon
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2013-02-04 21:40 UTC (permalink / raw)
  To: Matthieu Vachon; +Cc: kawa

On 02/04/2013 01:27 PM, Matthieu Vachon wrote:

> So, I need a way to activate the --main flag on a per module basis. If
> it does exist right now, I'm more then willing to implement it via a
> new `module-compile-options` keyword. What do you think of such
> option?

That seems like a good plan.

You might want to look at how on 2011-11-15 I added support for:
(module-compile-options full-tailcalls: #t)
We want:
(module-compile-options main: #t)
and the logic should be very similar (though simpler, since the
flag is a pure boolean, and per-module rather than per-lambda).
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about command-line-arguments and main method
  2013-02-04 21:40     ` Per Bothner
@ 2013-02-04 22:04       ` Matthieu Vachon
  2013-02-06  4:28         ` Matthieu Vachon
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Vachon @ 2013-02-04 22:04 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

On Mon, Feb 4, 2013 at 4:40 PM, Per Bothner <per@bothner.com> wrote:
> On 02/04/2013 01:27 PM, Matthieu Vachon wrote:
>
>> So, I need a way to activate the --main flag on a per module basis. If
>> it does exist right now, I'm more then willing to implement it via a
>> new `module-compile-options` keyword. What do you think of such
>> option?
>
>
> That seems like a good plan.
>
> You might want to look at how on 2011-11-15 I added support for:
> (module-compile-options full-tailcalls: #t)
> We want:
> (module-compile-options main: #t)
> and the logic should be very similar (though simpler, since the
> flag is a pure boolean, and per-module rather than per-lambda).
>

Ok thanks, I will look into this. I will come back if I have any
question about the implementation.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about command-line-arguments and main method
  2013-02-04 22:04       ` Matthieu Vachon
@ 2013-02-06  4:28         ` Matthieu Vachon
  2013-02-06  4:35           ` Per Bothner
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Vachon @ 2013-02-06  4:28 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

Ok, implemented the feature and it looks ok from the tests I made.
What is the correct procedure to submit a patch?

Thanks in advance,
Matt

On Mon, Feb 4, 2013 at 5:04 PM, Matthieu Vachon
<matthieu.o.vachon@gmail.com> wrote:
> On Mon, Feb 4, 2013 at 4:40 PM, Per Bothner <per@bothner.com> wrote:
>> On 02/04/2013 01:27 PM, Matthieu Vachon wrote:
>>
>>> So, I need a way to activate the --main flag on a per module basis. If
>>> it does exist right now, I'm more then willing to implement it via a
>>> new `module-compile-options` keyword. What do you think of such
>>> option?
>>
>>
>> That seems like a good plan.
>>
>> You might want to look at how on 2011-11-15 I added support for:
>> (module-compile-options full-tailcalls: #t)
>> We want:
>> (module-compile-options main: #t)
>> and the logic should be very similar (though simpler, since the
>> flag is a pure boolean, and per-module rather than per-lambda).
>>
>
> Ok thanks, I will look into this. I will come back if I have any
> question about the implementation.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question about command-line-arguments and main method
  2013-02-06  4:28         ` Matthieu Vachon
@ 2013-02-06  4:35           ` Per Bothner
  0 siblings, 0 replies; 7+ messages in thread
From: Per Bothner @ 2013-02-06  4:35 UTC (permalink / raw)
  To: Matthieu Vachon; +Cc: kawa

On 02/05/2013 08:27 PM, Matthieu Vachon wrote:
> Ok, implemented the feature and it looks ok from the tests I made.
> What is the correct procedure to submit a patch?

We don't really have any formal procedures, so far.
You can email the list, or email me privately
or attach it to a bugzilla bug report.

Either way, if I seem to forget to follow up, you
may have to remind me.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-06  4:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-04 18:15 Question about command-line-arguments and main method Matthieu Vachon
2013-02-04 20:59 ` Per Bothner
2013-02-04 21:27   ` Matthieu Vachon
2013-02-04 21:40     ` Per Bothner
2013-02-04 22:04       ` Matthieu Vachon
2013-02-06  4:28         ` Matthieu Vachon
2013-02-06  4:35           ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).