On 2012.5.13 3:41 PM, David Cantrell wrote:
> On Sun, May 13, 2012 at 02:13:28PM -0400, Numien wrote:
>> On 13/05/12 01:48 PM, Michael G Schwern wrote:
>>> The rpmbuild post reminded me of my list of stupid language designer 
>>> tricks.
>>> This is a file I add to every time I read about some stupid mistake (or
>>> "brilliant" feature) in a language and think "if I ever write a language I 
>>> am
>>> remembering not to do THAT!"
>>>
>> Also:
>> * No simple include statement
>>   * Javascript is one of the worst, but this is a far too common one.

I can forgive Javascript of that because it has no file operations by (good)
design and thus no way to load other files.

The only other instance I can think of is... damn I can't remember the name.
It's the one that makes URLs like /foo/bar/123,3598,235.html.  You write in
Java and everything, even the templates, is stored in Oracle.  Its include
statement took not a filename, not any sort of name, but the row ID of the
template you wanted to include.  Like "include 39593" because I totally know
what template 39593 is!


> Perl used to have this.  It was called #include.  It's a damned shame
> that -P got killed off.  Removing it was hateful.

Let's run one language through another language's preprocessor!  WHAT COULD
POSSIBLY GO WRONG?!  Let's just see what the old 5.10.1 perlrun man page says
about it...

    Because both comments and cpp directives begin with the # character,
    you should avoid starting comments with any words recognized by the
    C preprocessor such as "if", "else", or "define".

Oh.

    The "#!" line is stripped, so any switches there don't apply.

Oh dear.

    All lines that begin with (whitespace and) a "#" but do
    not look like cpp commands, are stripped, including
    anything inside Perl strings, regular expressions, and
    here-docs .

Oh my.

    In some platforms the C preprocessor knows too much: it
    knows about the C++ -style until-end-of-line comments
    starting with "//".  This will cause problems with
    common Perl constructs like

        s/foo//;

Well that's not good.

    It requires not only a working C preprocessor but also a
    working sed.

I can't imagine why they removed it.  Wait, yes I can!  Jarko and I wrote
those warnings after trying like hell to make it work in anything like a
reliable manner.

And if that all works, or if you implemented it sanely as an include()
keyword, you have a language construct that cut & pastes code without regard
to lexical encapsulation.  Greeeeeeeat.

If you think you need that, step away from the keyboard, take a nice walk
outside and rethink your design.  Or write out open + eval long hand.


-- 
29. The Irish MPs are not after "Me frosted lucky charms".
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to