--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-internals+unsubscribe@googlegroups.com.
Btw why rx and not jusr r?
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
Doesn't look like this is documented: http://docs.scala-lang.org/overviews/core/string-interpolation.html.
We have previously used pattern matching with quasiquoting interpolators.
There's currently a problem with UnApply nodes, which prevents the full power of macros from being used in pattern matching, though the patch we applied to fix that is tiny. Denys (in /cc) knows the details.
Hi Adriaan,
On 04/17/13 09:28, Adriaan Moors wrote:
I was being serious. Isn't it expected that regexes look like perl
accidents?
Well, probably :-)
But still, I like
val Complete = """complete@(\d*)""".r
more than
rx"""complete@(\d*)${I(pos)}"""
Of course, that may be just because the former is more familiar.
The interesting bit I thought was defining the regex extractor inline,
complete with nested subpatterns. A testament to the tight integration of
string interpolation into the language. An example of Scala the Unifier.
Yes, I fully agree with that. However, I think it's a feature that has the potential of obfuscating real code. And, IMHO, that happens in the example you cited as 'Real use case'.
Bye,
Jan
Jan
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-internals+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Yes, you're right. This is a nice example of how Scala's power should be used judiciously.However, I think that's always more about defining guidelines of what's appropriate for your project/team, rather than restricting the whole language.At its core, string interpolation is simple. The translation is simply: drop $-prefixed holes from the string, pack the remaining parts in a call to StringContext, and tack on a call to the interpolator named in the prefix, with the holes as arguments. Since this is unified with the other concepts in the language, it becomes quite powerful. You can use macros to make a typesafe printf, use them as patterns, implement a quasi quoting library, replace xml matching (perhaps?).
I'm also pretty interested in using concrete object syntax for pattern matching, in combination with Lightweight Modular Staging. Right now, one can use concrete object syntax only to express the replacement code (the "right-hand side" of a rewrite rule), not the pattern (the left-hand side of a rewrite rule), at least I'd be happy to reuse a solution for having concrete object syntax in matching.
See for instance this example (from http://arxiv.org/abs/1210.6284v1, page 6, also published at AOSD'13):val mergeFilters = ExpTransformer {case Sym(Filter(Sym(Filter(collection, pred2)), pred1)) ⇒collection.filter(x ⇒ pred2(x) && pred1(x))}The pattern here, in concrete object syntax, is something like "collection.filter(pred2).filter(pred1)".
you're right -- the problem is that the code expects a selection of an unapply[Seq] method that has a symbola block's symbol is nullthe symbol is used to determine whether the call is an unapply or an unapplySeq, so not sure how to do that for a block