On Sun, 18 Sep 2016, Sven Schreiber wrote:
Hi,
this is a quite fundamental remark I guess, but at the same time perhaps
doesn't affect too many concrete things.
I think that hansl still might resemble C too much in some aspects, and the
only real reason that I can see is that the gretl founders come from the C
background.
* The "printf" command:
For newcomers something like 'printf "hi: %s, %d", s1, d1' must look
horrible. In other languages including even Ox or --I believe-- C++ it is
possible to write things in the natural ordering, so in hansl this would
become something like:
'print "hi: " ~ s1 ~ d1'
Of course, for more finetuned control the current printf possibilities would
still be needed, but for many cases a default formatting of numbers would be
enough I think.
Both Matlab and R have sprintf. I take this as an indication that the
concept itself is not only valid, but appropriate to a high-level
language. But I admit you have a point; the number of times people have
said to me that "printf" is incomprehensible is impossible to
over-estimate.
I guess we could introduce a refinement to the current incarnation of
"print" in two directions:
* enable print to output expressions rather than simple variables (we
alredy have eval for that though)
* envisage some syntax so that you have a pre-cooked set of "sensible"
choices via a multi-argument "print" _function_, as in
print("hi:", stringvar, "!, you are the", n, "-th person I've
met!")
which would also have the advantage of handling expressions natively.
In this example, the idea would be that if "n" is an integer, we
automatically apply "%d", otherwise we go for "%g", etcetera
etcetera.
* Function names like "strstr": Tastes will vary here, but
when we discussed
whether or not the name of the function was intuitive for what it does, the
only real argument was that it's just the C name. But IMHO for the hansl user
it should be irrelevant whether gretl in the background is implemented in C
or whatever other language.
This is a matter of taste, as you say; I guess we could perhaps be more
cautious in the future if/when we introduce new functions.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------