Re: Heredoc strings

new topic     » goto parent     » topic index » view thread      » older message » newer message
jeremy said...

I think we need to really think this one through. Although this ability is great, I am not sure it's the best way of going about it. Tabs and Spaces should both be alowed and the syntax is a bit cumbersome/weird, however I understand it's purpose.

Are their any other implementation ideas on this subject?

Looking around the InterWebs, it seems that indentation of heredocs is pretty rare. I found this perl example, and another ruby-emacs patch that seem to both basically ignore the whitespace of the start line.

perl said...

use Filter::Indent::HereDoc; 
{ 
  { 
    print <<EOT; 
    Hello, World! 
    EOT 
  } 
} 
# This will print "Hello, World!" and stop at EOT 
# even though the termination string is indented. 

ruby-emacs said...

Without the patch, here-doc terminators are considered to end at the 
first non-word character.  For example, `ruby-parse-partial' would think 
that the here-doc continues until line 5 of the following: 
     
  1  begin 
  2    puts <<-end_here_doc 
  3      "Hear this, Doc?" 
  4    end_here_doc 
  5  end 

I think these are pretty reasonable compromises, especially considering the standard text editor behavior of duplicating the whitespace after hitting return.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu