[erlang-questions] For your amusement--why doesn't this compile?

john.hughes <>
Mon Jan 30 16:55:06 CET 2017


Actually, it is an error. As you can see by compiling this instead:

-module('Aaargh!!').
-define(PLEASE_DONT).
-ifndef(PLEASE_DONT).
-error("Weird!").
-endif.

2> c('Aaargh!!').
Aaargh!!.erl:2: badly formed 'define'
Aaargh!!.erl:4: -error("Weird!").
error

Curiouser and curiouser...

John

From: Alex S. 
Sent: Monday, January 30, 2017 4:50 PM
To:  
Cc:  
Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?

It’s considered an unknown module attribute, and those aren’t errors.

  30 янв. 2017 г., в 18:38,  написал(а):

  So why isn’t that reported as an error?

  John

  From: Alex S. 
  Sent: Monday, January 30, 2017 4:31 PM
  To:  
  Cc:  
  Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?


    30 янв. 2017 г., в 18:24, <> <> написал(а):

    Here’s a behaviour that’s had me tearing my hair today. Consider this module:

    -module('Aaargh!!').
    -define(PLEASE_DONT).
    -ifndef(PLEASE_DONT).
    -compile({parse_transform,undefined_parse_transform}).
    -endif.

    It fails to compile, with one simple error message:

    20> c('Aaargh!!').
    Aaargh!!.erl: undefined parse transform 'undefined_parse_transform'
    error

    If you can see why, you’re more an Erlang wizard than I am!

  Easy enough, there’s no one-argument define().

  Define it to true if you don’t care about the value.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170130/146f7331/attachment.html>


More information about the erlang-questions mailing list