Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Jörg F . Wittenberger

On Mar 24 2013, Moritz Heidkamp wrote:


Jörg F. Wittenberger joerg.wittenber...@softeyes.net writes:

Now I wanted to kick out need to keep duplicates of
the requirements; once in the uses cluse and below in
the import list.


Can give an example of what you refer to as import list?


(declare (unit foo)
;; this are my uses declarations
(uses bar foobar library)
;; end of uses declarations
)

(module
foo *
;; this is my import list:
(import bar foobar library)
;; end of import list
)



Moritz



___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Jörg F . Wittenberger

On Mar 24 2013, Peter Bex wrote:


On Sun, Mar 24, 2013 at 11:05:49PM +0100, Jörg F. Wittenberger wrote:

For some reason, several - though not all - procedures
turn out to be undefined (e.g. resolve to an unbound value
and then segfault accordingly).



Segfaults should only happen if aggressive optimizations are
enabled.


To me this looks (at the moment) as if the uses clause enforce
the correct initialization order, while the imports just declare
what's seen by the compiler.


Sounds like you may have some phasing issues; definitions in a
module aren't seen by macros defined in the same module, unless
you define-for-syntax them.  Converting old-style Scheme into
modules is kind of tricky, since with older code you could be a
lot sloppier about which definitions are available when.  Now you
have to be precise about at which level a definition exists.

However, without some concrete examples, we can only guess why
stuff isn't working for you.


Nah, the concrete example I gave could be expanded.  Though
I hope we can get away without.

I have an tedious, but otherwise simple task to get those
syntax definitions imported.  The compiler will complain.

What's more tricky is that bindings, e.g., make-hash-table
resolve to unbond in the runtime initialization even though
there is an (import srfi-69) in the module.

I can fix this by giving a (uses srfi-69) before the module.
But that's precisely what I feel it's wrong.



Cheers,
Peter




___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Moritz Heidkamp
Jörg F. Wittenberger joerg.wittenber...@softeyes.net writes:
 (declare (unit foo)
 ;; this are my uses declarations
 (uses bar foobar library)
 ;; end of uses declarations
 )

 (module
 foo *
 ;; this is my import list:
 (import bar foobar library)
 ;; end of import list
 )


Ah, alright, try to drop the `declare' and replace `import' with `use'
except for `chicken', `scheme' and `foreign' as well as all modules /
units from which you only want to import syntax (although using `use'
here has the same effect if all the module exports is syntax anyway).

So your example would probably become something like this:

  (module foo *

  (import chicken scheme)
  (use bar foobar library)

  )


Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Peter Bex
On Mon, Mar 25, 2013 at 10:07:15AM +0100, Jörg F. Wittenberger wrote:
 What's more tricky is that bindings, e.g., make-hash-table
 resolve to unbond in the runtime initialization even though
 there is an (import srfi-69) in the module.
 
 I can fix this by giving a (uses srfi-69) before the module.
 But that's precisely what I feel it's wrong.

import only loads the import library, it doesn't load the actual code.
For that you need to use require-library, or you can change the
import statement to be (require-extension srfi-69) or (use srfi-69),
which both loads and imports.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Jörg F . Wittenberger

On Mar 25 2013, Peter Bex wrote:


On Mon, Mar 25, 2013 at 10:07:15AM +0100, Jörg F. Wittenberger wrote:

What's more tricky is that bindings, e.g., make-hash-table
resolve to unbond in the runtime initialization even though
there is an (import srfi-69) in the module.

I can fix this by giving a (uses srfi-69) before the module.
But that's precisely what I feel it's wrong.


import only loads the import library, it doesn't load the actual code.
For that you need to use require-library, or you can change the
import statement to be (require-extension srfi-69) or (use srfi-69),
which both loads and imports.


These both don't cut it for me.

I'm using rather often (import (only module ) (except from sonthing))

Both use and require-extension seem to import all bindings.

Also at the moment I can't really get the thing to use the statically
bound .o files reliably.  The stripped down test case picks it up.
But in the full code, it fails with ##sys#require not finding the
code.

What to do?



Cheers,
Peter




___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Peter Bex
On Mon, Mar 25, 2013 at 10:52:39AM +0100, Jörg F. Wittenberger wrote:
 On Mar 25 2013, Peter Bex wrote:
 These both don't cut it for me.
 
 I'm using rather often (import (only module ) (except from sonthing))
 
 Both use and require-extension seem to import all bindings.

Please read the manual; USE accepts these import specifiers as well, and
like I pointed out before, you can also use require-library followed by
an import (the require-library form just loads the code and makes it
available).

 Also at the moment I can't really get the thing to use the statically
 bound .o files reliably.  The stripped down test case picks it up.
 But in the full code, it fails with ##sys#require not finding the
 code.

I don't understand what you mean by this.  USE doesn't work with
statically linked objects, only dynamically linked libraries.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Jörg F . Wittenberger

On Mar 25 2013, Peter Bex wrote:


On Mon, Mar 25, 2013 at 10:52:39AM +0100, Jörg F. Wittenberger wrote:

On Mar 25 2013, Peter Bex wrote:
These both don't cut it for me.

I'm using rather often (import (only module ) (except from sonthing))

Both use and require-extension seem to import all bindings.


Please read the manual; USE accepts these import specifiers as well, and


Sorry, I'm confused.  A moment ago I tried and it complained.
Dunno what I did wrong.


like I pointed out before, you can also use require-library followed by
an import (the require-library form just loads the code and makes it
available).


OK, so how would this be different from leaving things as they are,
i.e. (declare (uses ..)) instead of re-quire-library?
(Both followed by an import)

Any advantage in using require-library?




Also at the moment I can't really get the thing to use the statically
bound .o files reliably.  The stripped down test case picks it up.
But in the full code, it fails with ##sys#require not finding the
code.


I don't understand what you mean by this.  USE doesn't work with
statically linked objects, only dynamically linked libraries.

Cheers,
Peter



___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Peter Bex
On Mon, Mar 25, 2013 at 11:12:56AM +0100, Jörg F. Wittenberger wrote:
 On Mar 25 2013, Peter Bex wrote:
 Please read the manual; USE accepts these import specifiers as well, and
 
 Sorry, I'm confused.  A moment ago I tried and it complained.
 Dunno what I did wrong.

This has been added in 4.4.0, so it should work.  Maybe you had a typo?

 like I pointed out before, you can also use require-library followed by
 an import (the require-library form just loads the code and makes it
 available).
 
 OK, so how would this be different from leaving things as they are,
 i.e. (declare (uses ..)) instead of re-quire-library?
 (Both followed by an import)
 
 Any advantage in using require-library?

Well, if you want to make use of modules, I think this is needed.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-25 Thread Moritz Heidkamp
Jörg F. Wittenberger joerg.wittenber...@softeyes.net writes:
 However having the (declare (uses ...)) plus import does do the
 trick.

I don't think there is a shortcut form for that in core. I'm no expert
on statically linked modules, though.

Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-24 Thread Peter Bex
On Sun, Mar 24, 2013 at 11:05:49PM +0100, Jörg F. Wittenberger wrote:
 For some reason, several - though not all - procedures
 turn out to be undefined (e.g. resolve to an unbound value
 and then segfault accordingly).
 

Segfaults should only happen if aggressive optimizations are
enabled.

 To me this looks (at the moment) as if the uses clause enforce
 the correct initialization order, while the imports just declare
 what's seen by the compiler.

Sounds like you may have some phasing issues; definitions in a
module aren't seen by macros defined in the same module, unless
you define-for-syntax them.  Converting old-style Scheme into
modules is kind of tricky, since with older code you could be a
lot sloppier about which definitions are available when.  Now you
have to be precise about at which level a definition exists.

However, without some concrete examples, we can only guess why
stuff isn't working for you.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] to uses or not to uses

2013-03-24 Thread Moritz Heidkamp
Jörg F. Wittenberger joerg.wittenber...@softeyes.net writes:
 Now I wanted to kick out need to keep duplicates of
 the requirements; once in the uses cluse and below in
 the import list.

Can give an example of what you refer to as import list?

Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users