AnsweredAssumed Answered

How do pointers work in AEL?

Question asked by vgreer on Jul 17, 2003
Latest reply on Jul 18, 2003 by mfredrik
Well, certainly AEL _looks_ like C, but just how much does it act like it?  

I'm trying to get multiple values back from functions using the unary * (dereference) and & (reference) operators.  I am, however, confused on how to use these properly.  The documentation on AEL says little more than that the dereference and reference operators are there but neither describes how to use them nor provides examples of their use.  

Now, in C, you'd get multiple return values by declaring pointers in your function header and/or prototype, e.g.:
void foo(int *bobby, char *sally, float *jesse);
but in AEL, there's no type specification to speak of, so I've been assuming the same function in AEL would look a little like this:
defun foo(bobby, sally, jesse);
and that when calling the function I'd just put in variable references like so:
foo(&roberto, &sallina, &angialina);
whilst defining the function using dereferencing when I use the pointer variables, e.g.:
defun foo(bobby, sally, jesse)
{
*bobby = 7*6+3*4;
*sally = overDoIt(local_var_a);
*jesse = sqrt(2);
return;
}
Is this going to get me what I want?  What if the variables I'm passing are arrays?  Are array variables inherently pointers like in C and not need referencing when passing to a function?  

Oh, and this is off topic, but while on the subject of just how much like C AEL is, can one define function prototypes prior to ones primary function (which calls all others, main in C) and define the functions after the primary function? E.g.:
defun foo(slart, er, bart, fast);
defun bar(lu, po, lo, co);

defun prog_starts_here(W, L, S, coil_sep)
{
...blah, blah, blah,...
return;
}

defun foo(slart, er, bart, fast)
{
...blah, blah,...
return;
}

defun bar(lu, po, lo, co)
{
...blah...
return;
}  

Outcomes