Re: -O3 and type inference

[email protected]
Newsgroups gmane.lisp.scheme.bigloo
Organization Inria
Message-ID <[email protected]>
Hi Bob,

> Hello,
> 
> I wrote this program
> 
> (module test)
> 
> (define (new-vector s)
>   (if (number? s) (make-vector s) (print "new-vector expects an integer size, but got keyword " s)))
> 
> (new-vector 5)
> (new-vector :BAD)
> 
> It compiles and works fine with -O2, but with -O3 I get this error when compiling (bigloo 4.2b):
> 
>  
> 
> File "test.scm", line 7, character 171:
> #(new-vector :BAD)
> #            ^
> *** ERROR:toplevel-init
> Type error --  "int" expected, "keyword" provided
> 
>  
> 
> It seems to be enforcing the parameter type of make-vector on new-vector, as though (number? s) was always true.
> 
>  
> 
> I&#39;d like to use -Obench. Is there a way to avoid this error and/or a different way of writing this code that still allows the particular optimization -O3 is performing here?
Using the 4.3a, you get the following:

File "foo.scm", line 6, character 166:
#(new-vector :BAD)
#            ^
*** WARNING:bigloo:toplevel-init
Type error --  "int" expected, "keyword" provided

and when running the program:

new-vector expects an integer size, but got keyword :BAD

This looks like the expected behavior.

-- 
Manuel
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.