Am 18.09.2016 um 23:35 schrieb Allin Cottrell:
On Sun, 18 Sep 2016, Sven Schreiber wrote:
> (Side remark: What _is_ confusing about string literals in hansl
is
> the way how literals are given without quotes in a foreach loop --as
> in "loop foreach i peach pear plum"--, and probably in a few more
> places; but I've said that before.)
Granted. There are some places in hansl syntax where we really require a
string literal (or a set of same) but in the interest of (supposed)
user-friendliness we accept an unquoted version of the argument. I'm
prepared to admit that was probably a mistake ;-)
And I'm willing to admit that maintaining too much backwards
compatibility in a relatively young language as hansl might backfire in
those cases...
OK, but I'm not sure that people always know what's good for
them! (See
the US electorate's flirtation with Donald Trump.) The thing is, those
dumbed-down printf variants might look quite nice at first -- say, if
you have just one string and one variable to print -- but they don't
take you far, and in the end you have to learn printf anyway.
I must say I'm surprised to hear that and I don't agree at all. This is
the kind of argument that we usually hear against GUI programs and also
against syntax features like significant whitespace and so forth.
Basically most of the stuff that makes up gretl and hansl.
So let me wrap up a couple of alternative syntax suggestions (meaning
only one of them is needed):
1) Like Jack said, a new print() function with comma-separated arguments
which can be string literals or (scalar?) variable identifiers.
2) What about string conversion with the $-sign like we already can do
in loops? So that something like this would work:
check = 3
print "Value of check: $check" # wanted output: Value of check: 3
(I know, this would require escaping a literal '$'.)
3) A new built-in str() function as in my previous post, that does
conversion to string with some default formatting (%d, %g), such that my
'eval "hey: " ~ str(somenumber)' solution would work out of the box.
Thanks,
sven