FAQ for CLAIRE (Frequently Asked Questions)
last update: 19/11/2000
last version: 2.5.44
1. Classes
[1.1] Can an abstract class be ephemeral ?
-> no, but children Y of an abstract class X (therefore X <: ephemeral_obj
is impossible) can be made ephemeral explictly with ephemeral(Y)
[1.2] Why does C <: A and C <: A() behave differently ?
-> C <: A is a forward declaration.A forward declaration MUST be followed
by a real definition C <: A(...) before any instantiation is allowed
2. Methods
[2.1] when I define foo(), calling foo(12) does not produce an error
-> foo() does not exists in the "OO" vision of CLAIRE, it is a short cut
for foo(system), whereas the definition foo() -> .. creates foo@void
This is a known "design bug", which will be solved eventually :-) ...
by restoring an earlier choice (foo@meta_system)
[2.2] If I define a recursive method as an inline method (=>), an error
occur while compiling.
-> yes, you must be careful when defining an inline method (think of
a C macro). In the future, we'll try to generate a friendly warning ...
3. Imported
3.1 String
[3.1.1] I cannot change a character within a string using s["kjhk"] := 4 because
the compiler complains that the string is static
-> you must include the proper C++ compiling options (e.g., -fwritable-strings)
3.2 Floats
[3.2.1] I get float alignments error when compiling/running CLAIRE code with
float arrays
-> this problem occurs on some platform. You may contact other users in the
CLAIRE club, or wait ... a proper solution is coming
4. Bags, arrays
5. Tables
[5.1] Why cannot one use X :: table(domain = .., ...)
-> classes, tables can only be instantiated using the designated CLAIRE
syntax. You can actually do it dynamically by copying the code that is in
the interpreter, but you are on your own.
[5.2] Do hash tables exist in CLAIRE ?
-> yes. they can be static (with a name) : tables
or, they can be dynamic: lists. To use a list as a hash table, the
hash method is provided (cf. Appendix B). A little bit of packaging
is needed on your side to get exactly what you need.
[5.3] Can I create a table dynamically ?
-> no, unless you are knowledgeable about CLAIRE reflective nature. Creating
a table requires to fill the slots of the new objects with the proper values.
By looking at the definition of self_eval@Defarray in define.cl, you should
get all the necessary information to do so.
6. Objects
6.1 Instantiation
6.2 Properties and Operations
[6.2.1] I don't understand why I need to put parentheses around A op B op2 C
in some cases and not in others.
-> This is due to the handling of precendence by CLAIRE (cf. doc)
When you define a new operation (op) you must define its precedence accordingly
7. CLAIRE Instructions
7.1 Iteration
7.2 Variables
[7.2.1] I can create a variable at the top-level using x:t and no error
will occur
-> this is a known behavior for the top-level. You should not use variables
unless defined within a let. CLAIRE will prevent you from doing so by
mistake with regular variables (idents) but not with typed variable
declarations of the form v:t
[7.2.2] If I create a variable with the name of a slot x, then I cannot
access the value of the slot (self.x) !
-> Indeed, a local variable is a lexical variable that hides any binding
(name => object). Thus any named object with a name x will be hidden
by the definition of a variable with name x, including a property.
7.3 Trace
[7.3.1] Why cannot I use ~I as an option in trace (like in printf)
Printf works like a macro, with macroexpansion of the code, which supports the
~I option easily (substitution). On the other hand, trace is much more
classical and evaluates all its arguments (thus it is slower !).
8. Compiling