help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: function space


From: CdeMills
Subject: Re: function space
Date: Tue, 21 Feb 2012 14:26:24 -0800 (PST)

Sergei Steshenko-2 wrote
> 
> 
> To add to the confusion:
> 
> "
> octave:1> foo = [1 2 3]
> foo =
> 
>    1   2   3
> 
> 
> ".
> 
> Looks like a definitional (of the "m-language") defect to me.
> 
> Regards,
>   Sergei.
> 
> P.S. I hate both Python and 'make' languages for meaningful whitespaces.
> 
> 
You have an interesting comparison of programming languages on Wikipedia,
see in particular
http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)
http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(array)

You could look from many point of view on it. Mine is quite simple: the
perfect programming language does not yet exist.

For instance, I prefer R which makes a clear difference between function
calls and array indexing. The price to pay is that the concatenation
operator is not available, as it was "taken" for array indexing, and is
replaced by the function "c", abbreviation of cat.

OTOH, I'm porting a Octave program to C in order to run it on an embedded
platform. And I may assure you that the m-languages has some issues, but at
least operators works on vector and matrices. A single line like
x = y(some condition on y) % x and y are vectors
is translated in many lines:
- malloc an array of size (y), and test if the result is OK
- loop on y, test the condition, fill the temporary array
- count the number of non-null elements in the temporary array
- free x memory
- allocate x memory with the count you've computed (and test it)
- loop on the temp vector, find the non-null elements, use their index to
access y; concatenate the results in x
- do not forget to free the temp array

So yes there are a few flaws in the m-language, but you gain development
speed, compactness, no need to declare variables, memory is managed for you,
...

Regards
Pascal

--
View this message in context: 
http://octave.1599824.n4.nabble.com/function-space-tp4408021p4408551.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]