Ruby-dev summary 19198-19345

Sir Nobu [mailto:nobu.nokada@softhome.net]:

#this one combines use (since you may or may not use indenter)
s1 = <<|EOS
>================================
> #{hi}
> I have to indent this line
> And also this list line
> to make it look good
>================================
#{verylongstring} whose length I do not know/care
Lots of lines
follow here
and here… blahblah blah
I don’t mind… works all the time
EOS

Is this possible?

What possiblity? Yes for implementation, but I’m not sure
about the possiblity of adoption.

sorry. Yes, I only meant implementation.
Thank you.

I thought concatenated 2 literals, but noticed here-doc
wasn’t allowed after here-doc. This sample works as you
expected but looks strange a bit.

s1 = <<-EOS "
>================================
> #{hi}
> I have to indent this line
> And also this list line
> to make it look good
>================================
EOS
#{verylongstring} whose length I do not know/care
Lots of lines
follow here
and here… blahblah blah
I don’t mind… works all the time
"

Yes, you are right (as always). I see danger in dangling/orphan ‘"’. Can I
override quote(")?

Nobu Nakada

kind regards -botp

Hi,

···

At Fri, 17 Jan 2003 11:03:57 +0900, Peña, Botp wrote:

Yes, you are right (as always). I see danger in dangling/orphan ‘"’. Can I
override quote(")?

Sorry, what do you mean by `override quote’?


Nobu Nakada

OK, what about this suggestion in the OO spirit of Ruby?

 puts <<("interpolate", "indent", "indent terminator")|EOS
        >   string
        EOS

where the args can be strings or symbols, or possibly an array. I.e.
treat << as a method call that can take parmeters. If/when we get
named parameters then “margin” = “|”, or that could be done with a
hash, or some such could be added.

The main diffculty I see with this is: What is the |EOS passed in
as? I suppose at present it doesn’t have a type in the same way
that | in thing{|p} print p} doesn’t – it is probably just a token
for the parser. There may be difficulties here, because we can’t
insist that << has brackets for this style of parameterisation,
because of introducing an exception to the general rule that methods
don’t need parentheses.

    Hugh

OK, what about this suggestion in the OO spirit of Ruby?

 puts <<("interpolate", "indent", "indent terminator")|EOS
        >   string
        EOS

where the args can be strings or symbols, or possibly an array. I.e.
treat << as a method call that can take parmeters. If/when we get
named parameters then “margin” = “|”, or that could be done with a
hash, or some such could be added.

Hugh,

this is an interesting attempt at making here docs OO, yet it dosen’t quite
get there. the only thing i can see to do would be to take a block that the
here doc is within. maybe something like this:

  puts <<("interpolate", "indent", "indent terminator", "|") { 
     EOS
         >   string
         EOS
}

i take it the interoplate is a true/false argument? indent is equiv. to
tabto(n)? and what about the indent terminator, what is that?

but this sort of “long-winds” the whole deal…

no one responded to my suggestion of leaving here docs alnone and instead
adding a variant syntax to the %Q, %q construction. i.e.

%Q-| string

was it really such a bad idea?

···

On Friday 17 January 2003 04:19 am, Hugh Sasse Staff Elec Eng wrote:


tom sawyer, aka transami
transami@transami.net

OK, what about this suggestion in the OO spirit of Ruby?

 puts <<("interpolate", "indent", "indent terminator")|EOS
        >   string
        EOS

Hugh,

this is an interesting attempt at making here docs OO, yet it dosen’t quite
get there. the only thing i can see to do would be to take a block that the

No, it doesn’t get there, agreed…

here doc is within. maybe something like this:

  puts <<("interpolate", "indent", "indent terminator", "|") {
   EOS
         >   string
         EOS

}

i take it the interoplate is a true/false argument? indent is equiv. to

Defaults to false, if the string/symbol/… is present it is true…

tabto(n)? and what about the indent terminator, what is that?

    "interpolate"       -> EOS rather than 'EOS'
    "indent"            -> proposed | syntax
    "indent terminator  -> -EOS rather than EOS

but this sort of “long-winds” the whole deal…

Well, there could be short forms, but the idea is to make it clear
what is happening. This is “green hat” thinking at the moment,
trying to propose a more Rubyesque way to doing things, in the same
way that you can use $/ and friends if you like, but there are other
ways.

no one responded to my suggestion of leaving here docs alnone and instead
adding a variant syntax to the %Q, %q construction. i.e.

%Q-| string

was it really such a bad idea?

I prefer your %- because I don’t like the %Qxthisx having an
exception where x == -.

Actually, for the % things, I’d like one where \ is NOT interpreted.
But that’s for another thread, and I’m not sure it’s worthy enough
to raise. I was thinking of gsub( ‘/’, %b{} )…


tom sawyer, aka transami
transami@transami.net

    Hugh
···

On Fri, 17 Jan 2003, Tom Sawyer wrote:

On Friday 17 January 2003 04:19 am, Hugh Sasse Staff Elec Eng wrote:

so the set-margin here document thread seesm to be dying out, which is too
bad, b/c i would kill for something like this. i still think though that
perhaps the here docs themselves should be left alone. (and i am still left
wondering where here docs came from in the first place. anyone know?) i had
suggested a %Q-| notation, but it produces an expection in the normal %Q
syntax. perhaps this then?

%QQ| foo
> bar

i really want to see this feature in Ruby’s future!

···


tom sawyer, aka transami
transami@transami.net

                               .''.
   .''.      .        *''*    :_\/_:     .
  :_\/_:   _\(/_  .:.*_\/_*   : /\ :  .'.:.'.

.’’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:’.:::. | ’ ‘’ * ‘.’/.’ (/’.’:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
’…’ ‘:::’ === * /\ * .’/.’. ‘._____
* | : |. |’ .—"|
* | _ .–’| || | _| |
* | .-’| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /"\ | '-."". ‘-’ ‘-.’ '` |.

Hi,

so the set-margin here document thread seesm to be dying out, which is too
bad, b/c i would kill for something like this. i still think though that
perhaps the here docs themselves should be left alone. (and i am still left
wondering where here docs came from in the first place. anyone know?) i had
suggested a %Q-| notation, but it produces an expection in the normal %Q
syntax. perhaps this then?

%QQ| foo
> bar

It isn’t better to use another charater? For example,

bar = “bar”

dq = %L| foo
> #{bar}

sq = %l| foo

···

At Sun, 19 Jan 2003 18:08:02 +0900, Tom Sawyer wrote:
> bar


Nobu Nakada

works for me! what’s L stand for? Literal? Line? well, any character is fine
with me. can it be done?

···

On Sunday 19 January 2003 02:31 pm, nobu.nokada@softhome.net wrote:

It isn’t better to use another charater? For example,

bar = “bar”

dq = %L| foo
> #{bar}

sq = %l| foo
> bar


tom sawyer, aka transami
transami@transami.net

                               .''.
   .''.      .        *''*    :_\/_:     .
  :_\/_:   _\(/_  .:.*_\/_*   : /\ :  .'.:.'.

.‘’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:‘.:::. | ’ ‘’ * ‘.'/.’ (/’.‘:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
‘…’ ‘:::’ === * /\ * .‘/.'. ‘._____
* | : |. |’ .—"|
* | _ .–’| || | _| |
* | .-‘| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |.

Hi,

It isn’t better to use another charater? For example,

bar = “bar”

dq = %L| foo
> #{bar}

sq = %l| foo
> bar

works for me! what’s L stand for? Literal? Line? well, any character is fine

Line. All %-notations are literals, no?

with me. can it be done?

I’ve not tried it yet, just thought of.

···

At Mon, 20 Jan 2003 06:42:55 +0900, Tom Sawyer wrote:


Nobu Nakada