Bigloo: Type-hinting a function argument

99 views Asked by At

Suppose I have a procedure called foo, which returns a ::float which is meant to take the following arguments:

  1. A procedure taking two ::float arguments.
  2. A ::float
  3. Another ::float

How would I write an export for that function in the module part of the code? I have this so far:

(module bar
    (export (foo::float 'something ::float ::float)))

What should 'something be replaced by here?

2

There are 2 answers

0
Sven On BEST ANSWER

This question is similar to a previous bigloo question. There is currently no elegant way to do this. You should use ::procedure as the type of the first argument. This is no dramatic loss, because - in many cases - bigloo's type inference and flow analysis will find the errors you are trying to capture with type annotations.

2
soegaard On

Without actually testing here is my guess.

Define a type, say, fun-of-two-floats using type.

The example in the docs is:

(module foo 
   (extern
    (type *string->double
          (function double (string)) 
                    "double (*)(char *)")
    (macro cv::*string->double "convert")))

(print (*string->double-call cv "3.14"))

So my guess is that this will work:

(type fun-of-two-floats
      (function float (float float)))

(module bar
    (export (foo::float fun-of-two-floats ::float ::float)))

Docs are here: http://www-sop.inria.fr/mimosa/fp/Bigloo/doc/bigloo-28.html#Defining-an-extern-type