Gidday
I’m trying to figure out how “convert” works.
I see lots of examples of convert in use. For instance in “~/extempore/libs/core/”
there are several varieties of it where there is
(convert followed by one argument:
(bind-func vmean
(lambda (buf:i32* len:i64)
(/ (i32tod (vsum buf len)) (convert len)))) ;; from ~/extempore/libs/core/math.xtm
I guess convert can figure what type to convert into from the context.
In lots of others where there is a single argument only:
(convert (tref face 0))
(if (> z (convert 50)) … )
(adrange (convert 0) mx (convert 1)). ;; From algebraic_data_types.xtm
(convert null)
(convert 0)
(convert 1)
In other examples, e.g. from ~/extempore/libs/core/math.xtm , there is a third argument.
Presumably that’s the type you want to convert into.
(convert (pref buf i) double) ;; from ~/extempore/libs/core/math.xtm
Also:
(convert (tref-ptr str 1) i8*)
(convert (/ x 2.0) i64)
Then of course there are plenty of examples of specific conversion: i32tod, i32tof, i32toi64, i64toi32, dtof, etc.
I guess convert can handle varieties of other types defined by bind-type such as:
(bind-type Maybe <i1,!a>) ;; from ~/extempore/tests/core/adt.xtm
I could not find any place where a macro “convert” is defined. But (using Michele Pasin’s “https://extempore.michelepasin.org/index.html”) I did find this in runtime:
Defined in: https://github.com/digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
But compiler stuff is a bit beyond me at this stage so it would be nice to have sone guidelines on how “convert” works.
Anideas welcome.
Regards
George
--
You received this message because you are subscribed to the Google Groups "Extempore" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/extemporelang/4f85bd58-6c5a-42ff-a8fc-5c257364daeen%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/extemporelang/05535fc6-cd7a-42d2-a9d1-3f6531d5ce03n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/extemporelang/78fe7921-00dd-42ae-8e2d-1423103c2a30n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/extemporelang/1f413d15-65fe-4f2e-8273-6460e61c4cf6n%40googlegroups.com.