What does $(type1,type2) mean? What does $(expr1, expr2) mean? |
What does int @ mean? |
int *x = NULL;is not an error, but
int @x = NULL;is an error. Note that ``int @'' is shorthand for the more verbose ``int *@notnull''.
What does int *{37} mean? |
int *{1}
. Currently, the expression in the braces must be a
compile-time constant.
What does int *`r mean? |
What does `H mean? |
What does int @{37}`r mean? |
What is a pointer type's region when it's omitted? |
What does int ? mean? |
What does `a mean? |
What is a ``suitable'' type for a type variable? |
How do I cast from void *? |
What does _ (underscore) mean in types? |
_ x = new Pair(3,4);the compiler can easily infer that the wildcard stands for struct Pair @. In fact, if x is later assigned NULL, the compiler will infer that x has type struct Pair * instead.
What do `a::B, `a::M, `a::A, `a::R, `a::UR, `a::TR and `a::E mean? |
What does it mean when type variables don't have explicit kinds? |
void f(`a *`b x, `c * y, `a z);is shorthand for
void f(`a::B *`b::R x, `c::M * y, `a::B z)In type definitions, no inference is performed: an omitted kind is shorthand for ::B. For example,
struct S<`a,`r::R> { `a *`r x; };is shorthand for
struct S<`a::B,`r::R> { `a *`r x;};but
struct S<`a,`r>{`a *`r x;};is not.
What does struct List<`a,`r::R> mean? |
What is a @tagged union? |
What is abstract? |
What are the Cyclone keywords? |
What are namespace and using? |
What is fallthru? |
What is new? |
type @temp = malloc(sizeof(type)); *temp = expr;where type is the type of expr. You can also write
new { for i < expr1 : expr2 }to heap-allocate an array of size expr1 with the ith element initialized to expr2 (which may mention i).
How do I use tuples? |
What is {for i < expr1 : expr2}? |
How do I throw and catch exceptions? |
datatype exn { MyExn };The exception can be thrown with the statement
throw MyExn;You can catch the expression with a try/catch statement:
try statement1 catch { case MyExn: statement2 }If statement1 throws an MyExn and no inner catch handles it, control transfers to statement2.
datatype exn { MyIntExn(int) };Values of such exceptions must be heap-allocated. For example, you can create and throw a MyIntExn exception with
throw new MyIntExn(42);To catch such an exception you must use an &-pattern:
try statement1 catch { case &MyIntExn(x): statement2 }When the exception is caught, the integer value is bound to x.
How efficient is exception handling? |
What does let mean? |
let x,y,z;declares the three variables x, y, and z. The types of the variables do not need to be filled in by the programmer, they are filled in by the compiler's type inference algorithm. The let declaration above is equivalent to
_ x; _ y; _ z;There is a second kind of let declaration, with form
let pattern = expr;It evaluates expr and matches it against pattern, initializing the pattern variables of pattern with values drawn from expr. For example,
let x = 3;declares a new variable x and initializes it to 3, and
let $(y,z) = $(3,4);declares new variables y and z, and initializes y to 3 and z to 4.
What is a pattern and how do I use it? |
What does _ mean in a pattern? |
let $(_,y) = f(5);is a way to extract the second element of the pair and bind it to a new variable y.
What does it mean when a function has an argument with type `a? |
Do functions with type variables get duplicated like C++ template functions? Is there run-time overhead for using type variables? |
Can I use varargs? |
Why can't I declare types within functions? |
What casts are allowed? |
Why can't I implicitly fall-through to the next switch case? |
Do I have to initialize global variables? |
int x[37] = {};to declare a global array x initialized with 37 elements, all 0. Second, you can use the comprehension form
int x[37] = { for i < expr1 : expr2 }provided that expr1 and expr2 and constant expressions. Currently, expr2 may not use the variable i, but in the future it will be able to. Note that it is not possible to have a global variable of an abstract type because it is impossible to know any constant expression of that type.
Are there threads? |
Can I use setjmp and longjmp? |
What types are allowed for union members? |
Why can't I do anything with values of type void *? |
What is aprintf? |
How do I access command-line arguments? |
int main(int argc, char ?? argv);As in C, argc is the number of command-line arguments and argv[i] is a string with the ith argument. Unlike C, argv and each element of argv carry bounds information. Note that argc is redundant---it is always equal to numelts(argv).
Why can't I pass a stack pointer to certain functions? |
Why do I get an incomprehensible error when I assign a local's address to a pointer variable? |
How much pointer arithmetic can I do? |
What is the type of a literal string? |
Are strings NUL-terminated? |
How do I use malloc? |
Can I call free? |
void free(`a::A ?);
Is there a garbage collector? |
How can I make a stack-allocated array? |
int x[256];then uses of x have type int @`L{256} where L is the name of the block in which x is declared. (Most blocks are unnamed and the compiler just makes up a name.)
int y[] = { 0, 1, 2, 3 }; int z[] = { for i < 256 : i };To pass (a pointer to) the array to another function, the function must have a type indicating it can accept stack pointers, as explained elsewhere.
Can I use salloc or realloc? |
Why do I have to cast from * to @ if I've already tested for NULL? |
Why can't a function parameter or struct field have type `a::M? |
Can I see how Cyclone compiles the code? |
Can I use gdb on the output? |
Can I use gprof on the output? |
Is there an Emacs mode for Cyclone? |
Does Cyclone have something to do with runtime code generation? |
What platforms are supported? |
Why aren't there more libraries? |
Why doesn't List::imp_rev(l) change l to its reverse? |
Can I inline functions? |
If Cyclone is safe, why does my program crash? |
What are compile-time constants? |
How can I get the size of an array? |