Quantcast

For your amusement--why doesn't this compile?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

For your amusement--why doesn't this compile?

john.hughes
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!
 
John

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

Brujo Benavides-2
Well… this on the other hand, compiles:

-module(weird).
-define(PLEASE_DONT, true).
-ifndef(PLEASE_DONT).
-compile({parse_transform,undefined_parse_transform}).
-endif.

On Jan 30, 2017, at 12:24, <[hidden email]> <[hidden email]> wrote:

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!
 
John
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

Brujo Benavides-2
Strangely enough, this actually generates a different warning:

-module(weird).
-define(PLEASE_DONT).
-ifdef(PLEASE_DONT).
-compile({parse_transform,undefined_parse_transform}).
-endif.

1> c(weird).
src/weird.erl:2: badly formed 'define'

On Jan 30, 2017, at 12:27, Brujo Benavides <[hidden email]> wrote:

Well… this on the other hand, compiles:

-module(weird).
-define(PLEASE_DONT, true).
-ifndef(PLEASE_DONT).
-compile({parse_transform,undefined_parse_transform}).
-endif.

On Jan 30, 2017, at 12:24, <[hidden email]> <[hidden email]> wrote:

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!
 
John
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

Alex S.
In reply to this post by john.hughes

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

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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

john.hughes
So why isn’t that reported as an error?
 
John
 
Sent: Monday, January 30, 2017 4:31 PM
Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?
 
 
30 янв. 2017 г., в 18:24, <[hidden email]> <[hidden email]> написал(а):
 
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

Alex S.
It’s considered an unknown module attribute, and those aren’t errors.
30 янв. 2017 г., в 18:38, [hidden email] написал(а):

So why isn’t that reported as an error?
 
John
 
Sent: Monday, January 30, 2017 4:31 PM
Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?
 
 
30 янв. 2017 г., в 18:24, <[hidden email]> <[hidden email]> написал(а):
 
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

john.hughes
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
 
Sent: Monday, January 30, 2017 4:50 PM
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, [hidden email] написал(а):
 
So why isn’t that reported as an error?
 
John
 
Sent: Monday, January 30, 2017 4:31 PM
Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?
 
 
30 янв. 2017 г., в 18:24, <[hidden email]> <[hidden email]> написал(а):
 
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

José Valim-2
In reply to this post by Alex S.
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
Skype: jv.ptec
Founder and Director of R&D

On Mon, Jan 30, 2017 at 4:50 PM, Alex S. <[hidden email]> wrote:
It’s considered an unknown module attribute, and those aren’t errors.
30 янв. 2017 г., в 18:38, [hidden email] написал(а):

So why isn’t that reported as an error?
 
John
 
Sent: Monday, January 30, 2017 4:31 PM
Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?
 
 
30 янв. 2017 г., в 18:24, <[hidden email]> <[hidden email]> написал(а):
 
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: For your amusement--why doesn't this compile?

john.hughes
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 Smile
 
John
 
Sent: Monday, January 30, 2017 5:00 PM
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
Skype: jv.ptec
Founder and Director of R&D
 
On Mon, Jan 30, 2017 at 4:50 PM, Alex S. <[hidden email]> wrote:
It’s considered an unknown module attribute, and those aren’t errors.
30 янв. 2017 г., в 18:38, [hidden email] написал(а):
 
So why isn’t that reported as an error?
 
John
 
Sent: Monday, January 30, 2017 4:31 PM
Subject: Re: [erlang-questions] For your amusement--why doesn't this compile?
 
 
30 янв. 2017 г., в 18:24, <[hidden email]> <[hidden email]> написал(а):
 
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

 

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...