Andrew Mcelroy wrote in post #1063392:
> On Wed, Jun 6, 2012 at 10:04 AM, Bartosz Dziewoski
> <matma.rex / gmail.com> wrote:
>> 2012/6/6 Raphael B. <lists / ruby-forum.com>:
>>> That could be achieved (though not on a per file basis) with the -K
>>> flag, but I've read the -K flag could become deprecated, and that magic
>>> comments are the future. I don't understand how comments can get suchan
>>> importance in source code, and I want to learn more because I'm
>>> suspecting I am missing something.
>>
>> You can't always provide command-line options (or it might be troublesome).
>
> It is also worth noting that in shell scripts (ruby use to be thought
> of as a scripting language primarily)
> that #!/shell/path like
> #!/bin/bash
>
> is very common in perl and other shell script languages.
> So to see #utf-8 is to me more of a homage to declaring interpreter
> path than anything else.
> infact in a .cgi file
> #!/usr/bin/ruby is perfectly valid
>
> Andrew McElroy

The hashbang/shebang line is read by the current shell to know which interpreter should be run to execute the script, and the interpreter actually running the script ignores this line, because it is indeed a comment for him!

The situation with the encoding comment is quite different. It is a comment not ignored by the interpreter running the script. A semantic comment seems an oxymoron to me, but I'm interested to know how it came to become the preferred solution. Doesn't it make it harder now that ruby comments can't be ignored semantically?

Raph