Yeah, it may be awhile before I have enough time to learn ruby
for the weird stuff (e.g. heredocs), but most of the edge
cases are just edge cases and I think I can deal with those.
-mental
Then ditch heredocs. I can’t think of a case where I desperately needed
a heredoc over, say, %q{}.
As far as Ruby goes, I’m definitely going to need your help
for the weird stuff (e.g. heredocs), but most of the edge
cases are just edge cases and I think I can deal with those.
-mental
Then ditch heredocs. I can’t think of a case where I desperately needed
a heredoc over, say, %q{}.
+1
especially for stuff like multiple here docs headers in one line:
a=<<EoA, b= <<EoB
fofofo
EoA
blabla
EoB
On Wed, 2005-12-21 at 07:32 +0900, Berger, Daniel wrote:
Then ditch heredocs. I can’t think of a case where I desperately needed
a heredoc over, say, %q{}.
That’s the point of doing a subset grammar to begin with – we can leave
all the weird stuff like heredocs until last.
But heredocs are a part of Ruby’s grammar, so we are going to have to
accommodate them eventually. It’s doable, just funky.
-mental
On 20/12/05, Berger, Daniel [email protected] wrote:
Then ditch heredocs. I can’t think of a case where I desperately needed
a heredoc over, say, %q{}.
I use heredocs often. A grammar that doesn’t support heredocs won’t be
a Ruby grammar.
-austin
On Thu, 22 Dec 2005, Austin Z. wrote:
On 20/12/05, Berger, Daniel [email protected] wrote:
Then ditch heredocs. I can’t think of a case where I desperately needed
a heredoc over, say, %q{}.
I use heredocs often. A grammar that doesn’t support heredocs won’t be
a Ruby grammar.
agreed. it’s extremely difficult to do any serious metaprogramming
without
them. here is a snippet from something i was working on yesterday:
def xx_config_attr attr, default = nil
module_eval <<-code
module InstanceMethods
def #{ attr } *argv
if argv.empty?
if defined? @#{ attr }
return @#{ attr }
else
return(self.class.send("#{ attr }"))
end
else
return(send("#{ attr }=", argv.shift))
end
nil
end
def #{ attr }= value
@#{ attr } = value
end
end
module ClassMethods
def #{ attr } *argv
if argv.empty?
if defined? @#{ attr }
return @#{ attr }
else
ancestors.each do |a|
next if self == a
if a.respond_to? "#{ attr }"
return(a.send("#{ attr }"))
end
end
end
else
return(send("#{ attr }=", argv.shift))
end
nil
end
def #{ attr }= value
@#{ attr } = value
end
end
def self::#{ attr } *argv
if argv.empty?
if defined? @#{ attr }
return @#{ attr }
end
else
return(send("#{ attr }=", argv.shift))
end
nil
end
def self::#{ attr }= value
@#{ attr } = value
end
code
send "#{ attr }=", default
end
this kind of stuff is extremely difficult to code if you are limited to
symbols like {,(,{, etc to delimit the string. this is true anytime
your
string contains arbitrary code. heredocs make it possible.
regards.
-a
On Wed, 21 Dec 2005 00:22:40 -0000, MenTaLguY [email protected] wrote:
But heredocs are a part of Ruby’s grammar, so we are going to have to
accommodate them eventually. It’s doable, just funky.
Just to chime in, I have to agree on that - AFAIU the reason for wanting
rid of yacc is because it limits the syntax, so I think it’s important
that the effort to find a replacement aim to (eventually) support
everything that’s currently supported. Otherwise, surely it’s a case of
better the devil you know…
(That said though, I’ve used ANTLR a little bit in Java and I’m certain
that if anything can do it, ANTLR can).