java hashtable

Wayne Richards <[email protected]>
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <20131113183319.GA13539@amd4000>
I'm getting unexpected results from hashtable-get/put! under the -jvm
target.  However, when using bigloo3.6a, the results look correct to me.

Makefile:
--------

PROG=bgtest
BGLFLAGS=-g -jvm -jvm-cinit-module -jvm-purify
OBJS= bigloo/test.class \
	${PROG}.class
BGLJAR=/usr/local/lib/bigloo/current/bigloo_u.zip 
all: .afile ${OBJS}
	java -classpath .:$(BGLJAR) $(PROG)

%.class: %.java
	javac -classpath .:$(BGLJAR) $<

bigloo/test.class: bigloo/test.scm
	bigloo ${BGLFLAGS} -c -o $@ $^

.afile: bigloo/test.scm
	bglafile $^ > $@

clean:
	rm -f $(OBJS) .afile

(The file /usr/local/lib/bigloo/current is a symbolic link.  I point this to
the bigloo version, then do a 'sudo make install' from the appropriate
source directory.)

bgtest.java:
-----------

import bigloo.test;

public class bgtest{
    public static void main(String args[]){
	test.add(3);
	test.add(3);
    }
}

bigloo/test.scm:
---------------

(module bigloo.test
	(java
	 (export add "add"))
	(export
	 (add ::int))
	)

(define *hash* (make-hashtable 20000))

(define (add count)
  (let ((keys (iota count)))
    (for-each
     (lambda (key)
       (let ((fnd (hashtable-get *hash* key)))
	 (hashtable-put! *hash* key "value")
	 (printf "key: ~s fnd: ~s\n" key fnd)))
     keys)))

Under bigloo 4.0b, output is 
make -k 
bglafile bigloo/test.scm > .afile
bigloo -g -jvm -jvm-cinit-module -jvm-purify -c -o bigloo/test.class
bigloo/test.scm
*** WARNING:bigloo:Incompatible package name and class path.
Package name for module bigloo.test is `.', class path is `bigloo'.
javac -classpath .:/usr/local/lib/bigloo/current/bigloo_u.zip
bgtest.java
java -classpath .:/usr/local/lib/bigloo/current/bigloo_u.zip bgtest
key: 0 fnd: #f
key: 1 fnd: #f
key: 2 fnd: #f
key: 0 fnd: #f
key: 1 fnd: #f
key: 2 fnd: #f

Under bigloo 3.6a, output is
make -k 
bglafile bigloo/test.scm > .afile
bigloo -g -jvm -jvm-cinit-module -jvm-purify -c -o bigloo/test.class
bigloo/test.scm
*** WARNING:bigloo:Incompatible package name and class path.
Package name for module bigloo.test is `.', class path is `bigloo'.
javac -classpath .:/usr/local/lib/bigloo/current/bigloo_u.zip
bgtest.java
java -classpath .:/usr/local/lib/bigloo/current/bigloo_u.zip bgtest
key: 0 fnd: #f
key: 1 fnd: #f
key: 2 fnd: #f
key: 0 fnd: "value"
key: 1 fnd: "value"
key: 2 fnd: "value"

Is there something wrong with my code?  If not, what has changed in
bigloo?

Wayne
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.