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

john.hughes@REDACTED john.hughes@REDACTED
Mon Jan 30 17:05:21 CET 2017


I think you’re right—this is our current hypothesis. I do think it would be kinder to complain about the –define, in the case where the parse transform fails... since it’s the error in the define which CAUSES the parse transform to fail! Maybe a failing parse_transform could be treated as an identity function as far as other errors are concerned... although, of course, there could be a LOT of other errors caused by the parse transform failing to run!

Damned if you do, damned if you don’t!

Thanks for joining in the fun 

John

From: José Valim 
Sent: Monday, January 30, 2017 5:00 PM
To: Alex S. 
Cc: John Hughes ; Erlang 
Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?

My bet is that the parse transform fails before a warning/error is emitted for the bad -define declaration. 

I am not sure there is much it could do, given the parse_transform itself could rewrite -define(Foo) to mean something else, disappearing with the error in the first place.

José Valim
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Mon, Jan 30, 2017 at 4:50 PM, Alex S. <alex0player@REDACTED> wrote:

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

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

    So why isn’t that reported as an error?

    John

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


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

      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.



  _______________________________________________
  erlang-questions mailing list
  erlang-questions@REDACTED
  http://erlang.org/mailman/listinfo/erlang-questions


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170130/e505ca6c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wlEmoticon-smile[1].png
Type: image/png
Size: 1046 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170130/e505ca6c/attachment.png>


More information about the erlang-questions mailing list