One more difference. tabto strips after string
interpolcation, whereas here-doc does before it.
hi = " hi"
s0 = %q{
#{hi}
how are you?
}.tabto(0)
=> “\nhi\nhow are you?\n”
s1 = <<|EOS
>#{hi}
> how are you?
EOS
=> “\n hi\n how are you?\n”
sir Nobu. Is this working on your own Ruby version/patch?
Btw, as Dave suggested, can we takeoff the EOS part? Or maybe we combine
both such that the ff is possible:
s1 = <<|EOS
>#{hi}
I do not have the indenter
> how are you?
me, too… but ruby takes care of me
EOS
At Fri, 17 Jan 2003 00:52:38 +0900, Dave Thomas wrote:
Btw, as Dave suggested, can we takeoff the EOS part? Or maybe we combine
both such that the ff is possible:
s1 = <<|EOS
>#{hi}
I do not have the indenter
> how are you?
me, too… but ruby takes care of me
EOS
Well, I don’t like it very much… it may mislead me sometimes.
For what it’s worth, I don’t like this much either. But I still think
there’s some merit in
s = <<|Hello
>World
I often use inline, multi-line strings, and being able to set a margin
for them would be quite useful.
It looks nice, and once I got inclined to it. But now we have
3 types of string literals, with string interpolation as
doublequote, without it as singlequote, and command
substitution as backquote. I wonder which it corresponds to.
For what it’s worth, I don’t like this much either. But I still think
there’s some merit in
s = <<|Hello
>World
I often use inline, multi-line strings, and being able to set a margin
for them would be quite useful.
It looks nice, and once I got inclined to it. But now we have
3 types of string literals, with string interpolation as
doublequote, without it as singlequote, and command
substitution as backquote. I wonder which it corresponds to.
We can impose a different character for each type:
s = <<|Hello
>I am #{interpoladed}
s2 = <<.I
.am
.not interpolated!
BTW, how accesible is ‘|’ in keyboards around the world? In Spanish ones
you need AltGR and the 2 keys are quite far away… OTOH I think it was
a single keypress in German keyboards (will check tomorrow).
For what it’s worth, I don’t like this much either. But I still think
there’s some merit in
s = <<|Hello
>World
I often use inline, multi-line strings, and being able to set a margin
for them would be quite useful.
It looks nice, and once I got inclined to it. But now we have
3 types of string literals, with string interpolation as
doublequote, without it as singlequote, and command
substitution as backquote. I wonder which it corresponds to.
We can impose a different character for each type:
s = <<|Hello
>I am #{interpoladed}
s2 = <<.I
.am
.not interpolated!
We can, but it’ll enforce to remember magical relation, whereas
quotations surrounding here-doc marker look more obvious, to me
at least.
BTW, how accesible is ‘|’ in keyboards around the world? In Spanish ones
you need AltGR and the 2 keys are quite far away… OTOH I think it was
a single keypress in German keyboards (will check tomorrow).
It needs SHIFT and 1 key in Japanese 106/109 keyboard and same
in English 101/104.
···
At Fri, 17 Jan 2003 06:32:48 +0900, Mauricio Fernández wrote:
It looks nice, and once I got inclined to it. But now we have
3 types of string literals, with string interpolation as
doublequote, without it as singlequote, and command
substitution as backquote. I wonder which it corresponds to.
We can impose a different character for each type:
s = <<|Hello
>I am #{interpoladed}
s2 = <<.I
.am
.not interpolated!
Ick. I much prefer Perl’s version, where
$foo = <<EOSTR;
bah, this is $interpolated
EOSTR
is interpolated and
$bar = <<‘EOSTR’;
$this is a literal ‘$’ followed by ‘this’.
EOSTR
is not. Using separate characters like that is just asking for
confusion, to my mind, especially when they don’t have any prior
associations to enhance their meaning. Why not at least reuse the
ones we already have?
-=Eric
···
On Fri, Jan 17, 2003 at 02:35:55AM +0900, nobu.nokada@softhome.net wrote:
–
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton.
For what it’s worth, I don’t like this much either. But I still think
there’s some merit in
s = <<|Hello
>World
I often use inline, multi-line strings, and being able to set a margin
for them would be quite useful.
It looks nice, and once I got inclined to it. But now we have
3 types of string literals, with string interpolation as
doublequote, without it as singlequote, and command
substitution as backquote. I wonder which it corresponds to.
We can impose a different character for each type:
s = <<|Hello
>I am #{interpoladed}
s2 = <<.I
.am
.not interpolated!
We can, but it’ll enforce to remember magical relation, whereas
quotations surrounding here-doc marker look more obvious, to me
at least.
Then we need a new syntax… I don’t quite like the following but it’s
the best I can think of right now:
s = <<<“|”
>Hello, #{interpolated}
s2 = <<<‘|’
> not interpolated!
BTW, how accesible is ‘|’ in keyboards around the world? In Spanish ones
you need AltGR and the 2 keys are quite far away… OTOH I think it was
a single keypress in German keyboards (will check tomorrow).
It needs SHIFT and 1 key in Japanese 106/109 keyboard and same
in English 101/104.
If we take over the world we could have a special keyboard for coding in
Ruby
At Fri, 17 Jan 2003 06:32:48 +0900, Mauricio Fernández wrote:
For what it’s worth, I don’t like this much either. But I still think
there’s some merit in
s = <<|Hello
>World
I often use inline, multi-line strings, and being able to set a margin
for them would be quite useful.
It looks nice, and once I got inclined to it. But now we have
3 types of string literals, with string interpolation as
doublequote, without it as singlequote, and command
substitution as backquote. I wonder which it corresponds to.
It looks nice, and once I got inclined to it. But now we have
3 types of string literals, with string interpolation as
doublequote, without it as singlequote, and command
substitution as backquote. I wonder which it corresponds to.
We can impose a different character for each type:
s = <<|Hello
>I am #{interpoladed}
s2 = <<.I
.am
.not interpolated!
Ick. I much prefer Perl’s version, where
This is the same way in Ruby, too.
$foo = <<EOSTR;
bah, this is $interpolated
EOSTR
is interpolated and
$bar = <<‘EOSTR’;
$this is a literal ‘$’ followed by ‘this’.
EOSTR
is not. Using separate characters like that is just asking for
confusion, to my mind, especially when they don’t have any prior
associations to enhance their meaning. Why not at least reuse the
ones we already have?
s =<<"
" I am #{Interpolated}
s =<<’
’ I am not!
The problem is it might be difficult to make it work with what we have
now:
int, notint = <<“INT”, <<‘NOTINT’
I am interpolated
INT
I am not
NOTINT
···
On Fri, Jan 17, 2003 at 07:03:11AM +0900, Eric Schwartz wrote:
We can impose a different character for each type:
s = <<|Hello
>I am #{interpoladed}
s2 = <<.I
.am
.not interpolated!
Ick. I much prefer Perl’s version, where
$foo = <<EOSTR;
bah, this is $interpolated
EOSTR
is interpolated and
$bar = <<‘EOSTR’;
$this is a literal ‘$’ followed by ‘this’.
EOSTR
is not. Using separate characters like that is just asking for
confusion, to my mind, especially when they don’t have any prior
associations to enhance their meaning. Why not at least reuse the ones
we already have?
I don’t suppose this would parse very well (seems that it would conflict
with already existing syntax), but it would be nice:
s1 = <<"I
"am
"#{interpolated}
s2 = <<'I
'am
'not
'#{interpolated}
Whether it be ‘|’ or something else, what I like about nobu’s proposal
with Dave’s suggested modification is that it’s easy to see visually where
the doc ends, and there’s no wacky end terminator hanging out (apparently)
in the middle of nowhere.
No matter what, it seems here-docs would become more complex and I don’t
think matz will finally make it.
then i suggest this: let us LET HERE DOCUMENTS BE. they are an adoption (from
Perl?), are they not?
instead let’s work the idea into the “Ruby Way”. and we can do this in, what i
think is, a very elegent manner akin to the indented terminator of here
documents:
non-substitution:
%q-|foo
> bar
with-substitution:
%Q-|foo
> #{Time.now}
of course we have our little shortcut for the later:
%-|foo
> #{Time.now}
and, how nice! we can use any character we like (except a blank space)
%-)foo
) bar
the trick of course is in the - dash, which obviously i stole from <<-HERE.
the only draw back to this, mind you is that: %Q-this- dosen’t fly. but
that’s one sinlge character that i think we can live without it.
···
On Thursday 16 January 2003 03:16 pm, Mauricio Fernández wrote: