-
Notifications
You must be signed in to change notification settings - Fork 0
-
How are strings implemented? Does Clay support UTF8?
Currently Clay strings are just mutable byte vectors stored on the heap. In the future, Strings will be immutable with better support for UTF8.
-
How do I get the largest value for an integer type?
Use
Greatest(Int),Greatest(Int64), etc.
-
How much space (in bytes) does a variant occupy?
Variants are implemented as tag + value. Since all values of the variant have the same size, the size of the variant is machine word size (for the tag) + size of largest variant member.
-
How do I dynamically dispatch the appropriate method for a variant?
Use the asterisk to dispatch on a variant value:
f(*v). For e.g., if you have a variant with two members, and a function overloaded for both member types:variant Shape (Circle, Square); define draw; overload draw(c:Circle) {...} overload draw(s:Square) {...}Then, to dynamically dispatch on a value
shapeof typeShape:draw(*shape); // where shape = Shape(...)
-
Are variant types closed or open?
Variants are open so you can add new member types to a variant after it has been defined. For e.g. if you have a variant defined as
variant Shape (Circle, Square);, you can expand it to include a new member withinstance Shape Triangle;
-
Benchmarks are slower than equivalent C or C++ code
Clay's library includes bounds check and integer overflow assertions by default, which adds about 10% overhead in typical code. Make sure you test with
-Dclay.DisableAssertionsto disable all assertions, or-Dclay.DisableAssertions.boundsChecks -Dclay.DisableAssertions.overflowChecksto disable only bounds and overflow check assertions, to get a fair comparison.
-
How do I build a debug or release version of Clay?
When running cmake, set the
CMAKE_BUILD_TYPEattribute toDebugorReleaseas needed. For e.g.:cmake -DCMAKE_BUILD_TYPE=Debug .. -
Clay complains about parser errors on
/*tokensOlder versions of GCC have a compiler bug that breaks Clay's parser. Try updating your GCC, or using Clang.
-
Clay won't compile because it says it requires LLVM 3.0, even though I have LLVM 3.x
LLVM minor revisions and developer versions are not source compatible. Only LLVM 3.0 (not 3.0svn) release is currently supported.