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.
OK, maybe this just me, but personally I hate, despise and deplore
the various supposedly "user-friendly" alternatives to C-style
printf as found in Ox, R and some other languages. I find it
terribly confusing to have to mix quoted string-literal chunks and
variable names, all comma separated, in a single statement. It gets
even more confusing when you want literal parentheses in the output.
With printf, you have a clear separation of just one string literal,
the format, and whatever variables or expressions you want to print.
Granted, there's a learning curve -- particularly if you want fine
control over the output (but typically you can't get fine control at
all with the alternatives) -- but you can get pretty decent results
in hansl just knowing two conversions: "%g" for numerical values and
"%s" for strings.
So I would be more inclined to try writing up a nice printf tutorial
for beginners than to mess with the text/variable mash-up approach.
* 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.
I agree the language of implementation in the background should not
govern the features of hansl visible to the user. However, one
design decision in hansl is to favour terse function-names, and in
the case of strstr I'm not sure there's a much better alternative
terse name for a function that searches string1 for an occurrence of
string2. Using the C name may not be ideal, but it has the small
advantage that C function-names are used in many other languages
besides C, so once you know what "strstr" does, you'll find it'll do
the same in quite a few languages.
All the same, if/when we introduce other C-workalikes in hansl, we
shouldn't just assume that they should be named as in C, if we can
come up with something more indicative of what the function does.
Allin