function news
by Allin Cottrell
Up till now, the definition of a user-function in gretl has
been required to follow this pattern:
function <function-name> (<parameters>)
<function-body>
[ return <return-type> <variable-name> ]
end function
where <...> indicates a placeholder and [...] indicates an
optional element (functions are not required to return anything).
This has served us OK, but it's a bit clunky. Consider writing a
function to multiply a matrix by 2 (I know, pretty silly). The
most compact version would be something like:
function mtwo (matrix m)
x = 2 * m
return matrix x
end function
I've now relaxed the requirement that return lines must match the
pattern above. You can now do
return <expression>
The price you pay for this is that you have to specify the return
type as part of the first line of the definition:
function <return-type> <function-name> (<parameters>)
For example,
function matrix mtwo (matrix m)
return m * 2
end function
For a function that does not return anything you can write
function void <function-name> ...
The old-style syntax is still supported alongside the new.
Eventually we may want to mark it as deprecated and, after a
suitable lag, remove support.
I'm not going to modify the manual on this point for the 1.8.3
release. If people can test the new syntax that would be
great.
Allin
15 years, 5 months
Re: stata 10 files (Allin Cottrell)
by Gordon Hughes
There was a fairly significant change in native file format between
Stata 9 and Stata 10. Stata 10 files are much less widely supported
than the earlier file format,.
In general, I find that the easiest option is to save files in Stata
9 format using the Stata command:
saveold "file_name.dta", replace
I use StatTransfer frequently which you can set to default to Stata 9
file format.
Gordon Hughes
>On Wed, 5 Aug 2009, Raz Lev wrote:
>
> > does gretl support stata 10 files?
>
>No, not yet.
>
> > i have been trying to open a few files but i get an error saying
> > 'this is not a valid stata file'
>
>Could you send me an example, please? If it's not too difficult
>we can add support.
>
>Allin Cottrell
15 years, 5 months
stata 10 files
by Raz Lev
hi
does gretl support stata 10 files?
i have been trying to open a few files but i get an error saying 'this is not a valid stata file'
thanks,
Raz
"I often see problems in the world and wonder why someone doesn't fix them. Then I realize that I am someone, and that makes me feel bad because it is all my fault."
http://dilbert.com/blog/entry/fixing_the_world/
15 years, 5 months
string typo
by Sven Schreiber
Hi,
I just ran the latest snapshot (Windows this time). The new appearance
of the function documentation is very useful! One typo:
"Matrx building"
I presume that .po file updates for 1.8.3 should be done soon?
thanks,
sven
15 years, 5 months
some function suggestions/questions
by Sven Schreiber
Hi,
in light of the recent discussion concerning mreverse() --for example we
don't want too many different functions for doing similar things-- I
would like to raise the following issues:
1) sort() and dsort(); IMHO it would be good to unify them into one
function with an optional argument to specify descending sorting, like so:
sort(a) or sort(a,0) : sorts ascending
sort(a,1): sorts descending
2) strcmp(): would it be possible to handle this with a comparison
operator like mystr1 == mystr2 and scrap the function?
3) if not, at least unify strcmp() and strncmp(), again using an
optional argument:
strcmp(a,b,5) would work just like strncmp(a,b,5)
Actually, this looks very straightforward, or am I missing something?
I'm aware these are backward-incompatible changes, so of course this
needs to be carefully discussed and thought through. These are just some
things I stumbled upon recently, I guess there are similar issues that
could be found if done systematically.
And one last thing: I may have asked this before, but having a function
similar to the command 'pergm' would be useful I think.
thanks,
sven
15 years, 5 months