[Top][All Lists]

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

Re: Introducing `cond-feature'

From: Ludovic Courtès
Subject: Re: Introducing `cond-feature'
Date: Wed, 06 Dec 2006 09:31:31 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)


Kevin Ryde <address@hidden> writes:

> Perhaps cond-expand could be extended.  Maybe `guile-foo' feature to
> mean one of guile's features list.

I'd be tempted to think that having a different construct is clearer.
Especially since it makes it unnecessary to add a magic `guile-' prefix
to feature names.

>>   (if (provided? 'stuff)
>>       (do-stuff)
> That should be ok though.  A good compiler will want to recognise and
> optimize things like that, and drop resulting dead code.

Performing this kind of optimization somehow breaks the
compilation/execution boundary (see the links Rob posted): `provide?' is
just a regular procedure, and as such its invocations should not be
evaluated at compilation-time (the same goes for `defined?').

Besides, using `provided?' this way can yield "unbound variable" errors,
depending on how the run-time system is implemented.  Suppose for
instance that `do-stuff' is bound only when feature `stuff' is provided:
a not-so-smart compiler/interpreter could try to lookup symbol
`do-stuff', even if `stuff' is not provided.

> (Gratuitous plug: in my guile-lint I look for a few forms like that,
> to suppress warnings in code that's intended for particular guile or
> module versions.)

That looks nice!  Why not make it a GNU project or at least advertise it
on the Guile web page or manual?


reply via email to

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