Problems using Jazz

2 views
Skip to first unread message

William

unread,
Mar 15, 2009, 1:48:00 PM3/15/09
to Jazz Scheme
I keep trying and keep failing at some basic tasks.
I have a bunch of gambit code that I would like to run/debug
with jazz, and i also want to do GUI development. But I just
can't get started. At the risk of seeming stupid, here is where
I am. I generally move quickly between different languages
and development environments, but doing so requires some
clues and familiar concepts to transfer across.

My strategy is to just create a simple project and run it,
but I cannot even do that!

Notes:

* Seems to be a problem creating a Gambit project with a capital
letter as first character of name, as in "Test".
Error says "Test.product" is defining "test.product"

* When you remove a product, can't create one with same name
Says "Project already exists"

* Why does the "Gomuko" sample take 5 seconds to respond after a
click? This looks really bad.

* I can't figure out how the project/module system works. To try to
learn, I created a new Gambit project. Then I created a Gambit file:

test.scm:
------------------------------
(library test3.main gambit
(define (foo)
(print "Hello World"))
)
------------------------------

Then I edited the "product.jazz" file:
------------------------------
(library test3.product jazz

(import (test3.main))

(definition (run)
(foo)
(thread-sleep! 2.5))
------------------------------

But the error says "test3.main" not found. How does the project know
to include my module?

Jeremie Lasalle Ratelle

unread,
Mar 15, 2009, 7:28:40 PM3/15/09
to jazzs...@googlegroups.com
> test.scm:
> ------------------------------
> (library test3.main gambit
>  (define (foo)
>    (print "Hello World"))
> )
> ------------------------------
>
> Then I edited the "product.jazz" file:
> ------------------------------
> (library test3.product jazz
>
> (import (test3.main))
>
> (definition (run)
>  (foo)
>  (thread-sleep! 2.5))

I don't think you can load a gambit file like this in jazz.

Here's what I do :

I create a standard scheme file in my project directory, then in my
product.jazz :

(import (jazz.io))

(definition (run)
(initialize-aliases)
(set-current-directory {Directory User "lib" REST_OF_THE
PATH_TO_YOUR_SCHEME_FILE})
(load YOUR_SCHEME_FILE))

Stephane Le Cornec

unread,
Mar 16, 2009, 6:58:40 PM3/16/09
to jazzs...@googlegroups.com
Here's a short {repository package module library} explanation.
Suppose that you have a short program that you want to jazzify.

$ cat yankee.scm
(define (xray . rest)
  (map (lambda (x) (* x x)) rest))
$ cat bravo.scm
(load "yankee")
(display (xray 1 2 3))
(newline)
$ gsi bravo
149
$

Since we're going to modularize it, I will create 2 packages and move
those files into alpha and zulu.

$ cat ~/jazz_user/lib/Zilch/src/zulu/yankee.scm
(module zulu.yankee
(define (xray . rest)
  (map (lambda (x) (* x x)) rest)))
$ cat lib/Dummy/src/alpha/bravo.scm
(module alpha.bravo
(require (zulu.yankee))
(display (xray 1 2 3))
(newline))
$ jazz
JazzScheme v2.1.2 beta
> (jazz.load-module 'alpha.bravo)
149
> ,q
$

For every repository, Jazz will scan the folder structure of the
packages to find {alpha/bravo.scm alpha/bravo.jazz
alpha/bravo/_bravo.scm alpha/bravo/_bravo.jazz}. If it finds 2 of
these in the same repository, it fails.

Now, the code above will fails on the merest typo, which is not
something we want for Jazz. Library will code-walk and warn of free
symbols.

(library alpha.bravo scheme
(require (zulu.yankee))
(native xray)
(display (xray 1 2 3))
(newline))
or
(library alpha.bravo scheme
(import (zulu.yankee))
(display (xray 1 2 3))
(newline))

In these sample, all symbols are known. {library require} are special
forms, {native import} are imported from the core dialect, {display
newline} from the scheme dialect, xray is imported or declared as
native.

Guillaume Cartier

unread,
Mar 18, 2009, 4:29:40 PM3/18/09
to jazzs...@googlegroups.com
On Sun, Mar 15, 2009 at 1:48 PM, William <w7c...@gmail.com> wrote:
>
> I keep trying and keep failing at some basic tasks.
> I have a bunch of gambit code that I would like to run/debug
> with jazz, and i also want to do GUI development. But I just
> can't get started. At the risk of seeming stupid, here is where
> I am. I generally move quickly between different languages
> and development environments, but doing so requires some
> clues and familiar concepts to transfer across.
>
> My strategy is to just create a simple project and run it,
> but I cannot even do that!
>
> Notes:
>
> * Seems to be a problem creating a Gambit project with a capital
> letter as first character of name, as in "Test".
> Error says "Test.product" is defining "test.product"

Could not reproduce this problem. It was probably fixed. Did you pull
the latest changes?

> * When you remove a product, can't create one with same name
> Says "Project already exists"

This is a misunderstanding due to a bad error message. It is not a
check for an existing project in the workbench but a check for an
existing directory where the project would end up being created. I
have improved the error message for all creation actions so that you
would now get :

Project already exists: C:/Home/jazz_user/lib/Test/

> * Why does the "Gomuko" sample take 5 seconds to respond after a
> click? This looks really bad.

It takes a long time because you are running the project interpreted
and both gomoku and c4 rely on a minimax algorithm to evaluate
variations to a depth of 4. But I totally aggree that for a newcomer
that doesn't know what is happening , it looks really bad. I added a
new module-uptodate-binary? primitive to return if a module has an
up-to-date binary and both projects are now using it to display a
warning message. Good point!

> * I can't figure out how the project/module system works. To try to
> learn, I created a new Gambit project. Then I created a Gambit file:
>
> test.scm:
> ------------------------------
> (library test3.main gambit
>  (define (foo)
>    (print "Hello World"))
> )
> ------------------------------
>
> Then I edited the "product.jazz" file:
> ------------------------------
> (library test3.product jazz
>
> (import (test3.main))
>
> (definition (run)
>  (foo)
>  (thread-sleep! 2.5))
> ------------------------------
>
> But the error says "test3.main" not found. How does the project know
> to include my module?
>
>

The element you are missing is: how does the module system find a
module? Given a module a.b.c how does it know what file to load that
will be defining the a.b.c module? As Stephane Le Cornec said, the
module system will try every package and assumes that inside a
package, module a.b.c will be found at one of the following :

- a/b/c.scm
- a/b/c.jazz
- a/b/c/_c.scm
- a/b/c/_c.jazz

This said, your test3.main library should then be in :
HOME/jazz_user/lib/Test/src/test3/main.scm. Note that a package can
define a starting 'root' for where its modules are located and by
default it is "src". This is why there is a /src/ in the above path.

PS: Be careful, the product run / update / build functions now receive
a 'descriptor' argument to have access to the product declaration
inside the package. Your run function will thus become :

(definition (run descriptor)
(foo)
(thread-sleep! 2.5))

Hope this helps make things clearer.

Guillaume Cartier

Reply all
Reply to author
Forward
0 new messages