assert(fn.tpe != null, tree) | | | g | false null[1] https://github.com/pniederw/expecty
By the way, obviously I need to eval the second argument, but that's enough macro fiddling for now - I was just going for the proof of wonderfulness.
Expecty was on my list from the day you first called attention to it.
I don't see any reason for _not_ having it on the standard library.
Why in the world would we stick to an inferior error message if a
superior alternative exists, if the API doesn't change?
Now, playing as the devil advocate just a bit here, it would disclose
code in error messages. Not a lot of code, granted, but some people
can be picky about it. And some people pick up identifier names they
really shouldn't, and wouldn't if they knew users would see those
names.
On Fri, Jun 29, 2012 at 3:38 PM, Paul Phillips <pa...@improving.org> wrote:
> I have long been very envious of the languages which can do useful things
> with asserts. Then came the macros...
>
> I adapted Peter Niederwieser's expecty[1] so it could be used with the
> signatures of assert/assume/require, then built the compiler with it.
> Look![2] I dare you to say there is anything better in this life or the
> next.
>
> Since I expect gmail will savage the formatting and thereby dampen my
> enthusiasm, I enclose only a tiny snippet in this email. See url [2] below
> for a handful of examples from actual open scala tickets.
>
> assert(fn.tpe != null, tree)
> | | |
> g | false
> null
>
> [1] https://github.com/pniederw/expecty
> [2] https://gist.github.com/3019862
--
Daniel C. Sobral
I travel to the future all the time.
--It's indeed mouth-watering! One concern of course is the code overhead in the assertions. How extra code is that? I assume there's no runtime cost for the success case, right? Even if these rich asserts produce a lot of extra code, I'd still be in favor of having them, but controlled under a compile-time option.Cheers- Martin
On Fri, Jun 29, 2012 at 3:38 PM, Paul Phillips <pa...@improving.org> wrote:
> I have long been very envious of the languages which can do useful things
> with asserts. Then came the macros...
>
> I adapted Peter Niederwieser's expecty[1] so it could be used with the
> signatures of assert/assume/require, then built the compiler with it.
> Look![2] I dare you to say there is anything better in this life or the
> next.
>
> Since I expect gmail will savage the formatting and thereby dampen my
> enthusiasm, I enclose only a tiny snippet in this email. See url [2] below
> for a handful of examples from actual open scala tickets.
>
> assert(fn.tpe != null, tree)
> | | |
> g | false
> null
>
> [1] https://github.com/pniederw/expecty
> [2] https://gist.github.com/3019862
It's indeed mouth-watering! One concern of course is the code overhead in the assertions. How extra code is that? I assume there's no runtime cost for the success case, right? Even if these rich asserts produce a lot of extra code, I'd still be in favor of having them, but controlled under a compile-time option.