stedolan / malfunction

Malfunctional Programming
Other
336 stars 19 forks source link

Floating values #5

Closed olleharstedt closed 5 years ago

olleharstedt commented 8 years ago

Hi!

How about adding a chapter to the spec about floats? This is what I've tried so far:

        (dum, List [
          (dum, Atom "block");
          (dum, List [
            (dum, Atom "tag");
            (dum, Int Obj.double_tag)
          ]);
          (dum, String "1.0")
        ]);

but

Fatal error: exception Malfunction_sexp.SyntaxError(_, "tag 253 out of range [0,199]")

The malf code (trying to make ref a = 1.0):

    (let ($a (block (tag 0) (block (tag 253) "1.0")))

Better to use vectors of length 1 for references?

olleharstedt commented 8 years ago

I saw IntArith module, but no FloatArith. If you give me some guidlines, I can try to implement it.

stedolan commented 8 years ago

At the moment, there's just no support for floats in malfunction. It's on my list, though! It'll need to be added in quite a few places: lexer, parser, interpreter, compiler, spec and testsuite.

Better to use vectors of length 1 for references?

Correct, since blocks are immutable. (Currently, there's no support for OCaml's records of mixed mutable and immutable fields).

olleharstedt commented 8 years ago

OK, good info. Yes, I understand it will be a deep change.

olleharstedt commented 8 years ago

FYI, I forked your project and started to work on float values.

xekoukou commented 5 years ago

@stedolan I would greatly appreciate if you add float values to the spec. In fact , I am only interested in float literals, since I can already use any Ocaml function.

It is for an agda backend. It is starting to work . It just needs floats (and unicode strings which can be mapped into MLF strings , and uchars which can be mapped to MLF Ints.)

stedolan commented 5 years ago

Floating-point support just added! Testsuite is limited, though, there's no serious testing of rounding / precision / conversions, etc.