Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Block Comments

Reply
Thread Tools

Block Comments

 
 
yesteray
Guest
Posts: n/a
 
      07-18-2009
What text, if any, is allowed on the the line after the =begin and
=end delimiters of block comments?

I have code that looks like this:

=begin Hello
=end Goodbye
p "I work"

and it prints "I work" on these versions of Ruby:

ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
ruby 1.9.0 (2008-07-25 revision 18217) [i686-darwin9.5.2]
jruby 1.3.0 (ruby 1.8.6p287) (2009-06-03 5dc2e22) (Java HotSpot(TM)
Client VM 1.5.0_19) [i386-java]

Normally I wouldn't think about this anymore, but he ruby-parser gem
(2.0.2) throws an error:

ruby_parser-2.0.2/lib/ruby_lexer.rb:385:in `rb_compile_error':
embedded document meets end of file. near line 1: "
Hello" (SyntaxError)

although it works if you remove the text after the =end.

Based on a cursory grepping of the sources, Ruby 1.9 source
(ruby-1.9.1-p129) never uses any text on the same line as the =begin
or =end delimiters and Rubyspec doesn't have any tests around block
comments. Rubyspec does have some =begin "Text", but not =end "Text"
comment delimiters.

I'd like to fix the ruby-parser gem, but this seems to be something of
a grey area. I've never seen anything that requires Ruby to accept or
reject =end Text delimiters on block comments, but the de facto
standard and practice seem to be in conflict. The standard is to
accept text after the =end; the practice seems to be to not do it.

Thoughts?

 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      07-18-2009
yesteray wrote:
> What text, if any, is allowed on the the line after the =begin and
> =end delimiters of block comments?
>


_The Ruby Programming Language_ specifically says that text can follow
=begin and =end as long as it's separated by at least one blank, and
shows an example of both =begin and =end statements will additional text
on the same line. The text is treated as part of the comment.

--
MagickWand for Ruby - http://magickwand.rubyforge.org/

 
Reply With Quote
 
 
 
 
Caleb Clausen
Guest
Posts: n/a
 
      07-19-2009
On 7/18/09, yesteray <> wrote:
> What text, if any, is allowed on the the line after the =begin and
> =end delimiters of block comments?
>
> I have code that looks like this:
>
> =begin Hello
> =end Goodbye
> p "I work"
>
> and it prints "I work" on these versions of Ruby:
>
> ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
> ruby 1.9.0 (2008-07-25 revision 18217) [i686-darwin9.5.2]
> jruby 1.3.0 (ruby 1.8.6p287) (2009-06-03 5dc2e22) (Java HotSpot(TM)
> Client VM 1.5.0_19) [i386-java]
>
> Normally I wouldn't think about this anymore, but he ruby-parser gem
> (2.0.2) throws an error:
>
> ruby_parser-2.0.2/lib/ruby_lexer.rb:385:in `rb_compile_error':
> embedded document meets end of file. near line 1: "
> Hello" (SyntaxError)
>
> although it works if you remove the text after the =end.


RedParse doesn't have this bug, tho there is a more obscure problem
with =begin blocks that I haven't figured out yet.

 
Reply With Quote
 
Yossef Mendelssohn
Guest
Posts: n/a
 
      07-20-2009
On Jul 18, 5:27=A0pm, Tim Hunter <TimHun...@nc.rr.com> wrote:
> _The Ruby Programming Language_ specifically says that text can follow
> =3Dbegin and =3Dend as long as it's separated by at least one blank, and
> shows an example of both =3Dbegin and =3Dend statements will additional t=

ext
> on the same line. The text is treated as part of the comment.


This appears to be an answer to the question possibly posed by
willfully ignoring everything following the first paragraph of the
post, including the code example.

--
-yossef

 
Reply With Quote
 
Tim Hunter
Guest
Posts: n/a
 
      07-20-2009
Yossef Mendelssohn wrote:
> On Jul 18, 5:27 pm, Tim Hunter <TimHun...@nc.rr.com> wrote:
>> _The Ruby Programming Language_ specifically says that text can follow
>> =begin and =end as long as it's separated by at least one blank, and
>> shows an example of both =begin and =end statements will additional text
>> on the same line. The text is treated as part of the comment.

>
> This appears to be an answer to the question possibly posed by
> willfully ignoring everything following the first paragraph of the
> post, including the code example.
>
> --
> -yossef
>
>


The OP says "What text, if any, is allowed on the the line after the
=begin and =end delimiters of block comments?," and "I've never seen
anything that requires Ruby to accept or reject =end Text delimiters on
block comments." My response was a quote from an authoritative
reference. Based on the lack of follow-up I assumed my response was
adequate.

Perhaps I was wrong. What do you think the OP was asking? What's your
answer to his question?

--
MagickWand for Ruby - http://magickwand.rubyforge.org/

 
Reply With Quote
 
Yossef Mendelssohn
Guest
Posts: n/a
 
      07-21-2009
On Jul 20, 5:34=A0pm, Tim Hunter <TimHun...@nc.rr.com> wrote:
> The OP says "What text, if any, is allowed on the the line after the
> =3Dbegin and =3Dend delimiters of block comments?," and "I've never seen
> anything that requires Ruby to accept or reject =3Dend Text delimiters on
> block comments." My response was a quote from an authoritative
> reference. Based on the lack of follow-up I assumed my response was
> adequate.
>
> Perhaps I was wrong. What do you think the OP was asking? What's your
> answer to his question?


Somehow my earlier reading seemed to focus on the lack of vertical
space between the =3Dend line and the code line beneath it, and I was
completely wrong about the point of the question.

--
-yossef

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Javascript 4 06-03-2006 02:00 PM
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Java 0 06-02-2006 06:35 AM
Comments format: comments extending over multi-line Monk C Programming 10 04-20-2005 05:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57