-
-
Save loverdos/1310344 to your computer and use it in GitHub Desktop.
| object Comment { | |
| def comment[T](t: => T): Unit = {} | |
| } | |
| // Usage | |
| comment { | |
| List(1, 2, 3).map(_ * 2) | |
| } |
I think the only reasonable answer is "why not?".
Nice, but how much will a ton of these slow down Scala's already-tortoisesque compiler?
exactly, why?
I have this in my utils too, I call it skip. :-)
Now, rename it example and integrate it into scaladoc.
Wouldn't using @elidable make more sense?
@retronym, interesting you mention that, I wrote a plugin that would allow exact that. The idea was to show the sources of a computation along with the result of the computation for using in presentations. It would make perfect sense to have it Scaladoc.
Thanx all for commenting. Even the "whys". There is no why when researching :) And as a matter of fact the conversation opened up the possibilities.
@pedrofurla Sounds cool! I get really worried when people add code examples to Scaladoc that will inevitably suffer bit-rot.
I have actually used it as a documentation tool too (as in: " to remember this algorithm" or "provide an alternative") and not just a throw-away comment.
@retronym @pedrofurla Personally, I think all examples tagged with @example should be compilable (ie, all includes necessary) and compiled -- as in, Scaladoc generates errors/warnings if they can't be compiled. I'll accept auto-importing of the class/object/whatever in question, however. :-)
@dcsobral yes, I totally agree. This makes me wonder how hard would it be to make the example taglet inject its contents into the ASTs, and even compile and run it and give back the result to the Scaladoc tool... Feels a lot harder than the plugin approach.
@loverdos And how do get the defined algorithms in outer scope? For the throw away I'd also use the @elidable magic...
@pedrofurla With the new expression trees that have recently entered the compiler, I think getting any algorithm should be much much easier now.
@loverdos Oh yeah, new doors of all crazy possibilities are now open.
Why?