-
Notifications
You must be signed in to change notification settings - Fork 32
CommonLarcenyPrimitiveTesting
Felix S. Klock II edited this page Jul 28, 2013
·
1 revision
#!rst
Type Testing for Common Larceny
===============================
The following types exist in Larceny. Each has a corresponding predicate that
indicates whether or not a given argument is of the type specified (e.g.
number?)
+------------+------------------------------+----------------+----------------+
| Type | Corresponding .NET Type(s) | Scheme methods | .NET methods |
| | | accept .NET | accept Scheme |
| | | type? | type? |
+============+==============================+================+================+
| complex | None | n/a | N |
+------------+------------------------------+----------------+----------------+
| number | System.Float, System.Double, | sometimes | sometimes* |
+------------+ System.Decimal**, +----------------+----------------+
| real | System.Byte, System.SByte, | sometimes | sometimes* |
+------------+ System.Int16, System.UInt16, +----------------+----------------+
| rational | System.Int32, System.UInt32, | sometimes | sometimes* |
+------------+ System.Int64, System.UInt64 +----------------+----------------+
| integer | | sometimes | sometimes* |
+------------+------------------------------+----------------+----------------+
| boolean | System.Boolean | Y | Y |
+------------+------------------------------+----------------+----------------+
| procedure | closest match would be the | don't know | don't know |
| | System.Delegate and | | |
| | System.MulticastDelegate | | |
| | classes | | |
+------------+------------------------------+----------------+----------------+
| pair | None | n/a | N |
+------------+------------------------------+----------------+----------------+
| null | None | n/a | N |
+------------+------------------------------+----------------+----------------+
| list | None | n/a | N |
+------------+------------------------------+----------------+----------------+
| symbol | None | n/a | N |
+------------+------------------------------+----------------+----------------+
| char | System.Char | N | N |
+------------+------------------------------+----------------+----------------+
| string | System.String | Y | Static, not |
| | | | instance |
+------------+------------------------------+----------------+----------------+
| vector | System.Array | sometimes | N |
| | (maybe System.Vector?) | | |
+------------+------------------------------+----------------+----------------+
| bytevector | System.Array of type | | |
| | System.Byte | | |
+------------+------------------------------+----------------+----------------+
\* .NET methods that consume numeric arguments do not work unless the right
type of numbers are used. Specifically, if a method expects a double, and an
integral scheme number is supplied, it will not work. ``(System.Math.Sqrt 4)``
does not work, whereas ``(System.Math.Sqrt 4.0)`` does.
\** The type System.Decimal isn't converted properly to a number in scheme.
It appears as though when a .NET method produces an array it is automatically
translated to a vector so the scheme world can understand it, but there is no
implicit conversion going the other way. SOME methods that expect arrays as
input do not function when given vectors as input. However, SOME do.
``(System.String.Join "-" (vector "foo" "bar"))`` works.
``(System.IO.File.WriteAllBytes "C:\TEMP\temp-file.txt" (System.IO.File.ReadAllBytes "C:\TEMP\original-file.txt"))`` does not work.
System.Float.class
isn't there.
Both System.IO.File.ReadAllBytes
and System.IO.File.WriteAllBytes
work for Will.
See CommonLarcenyMarshalling.