Re: -O3 and type inference

"bob eob" <[email protected]>
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <trinity-abb7e3c2-6fda-4c92-bd44-c57657473cba-1472767344708@3capp-mailcom-bs04>
That's great, thanks a lot Manuel.

Sent: Monday, August 29, 2016 at 6:55 AM

From: [email protected]

To: "bob eob" <[email protected]>

Cc: [email protected]

Subject: Re: [bigloo] -O3 and type inference

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.