Re: Selective String Interpolation

2006-02-19 Thread Jonathan Lang
Brad Bowman wrote:
> I don't like the idea of sharing the adverb between escaping and
> force-interpolating since stacking other adverbs can turn q into qq
> and vice-versa.  That's a minor quibble though.

And a reasonable one as well.  I was trying to minimize the
proliferation of adverbs, but I may have gone overboard by trying to
fit crucially different things under the same tent.  Separate :esc and
:interp adverbs probably would be better overall.

> Analogous issues occur with quasiquoting, so a solution that can be
> naturally shared would be ideal.  CODE :interp(`) { say `$a + $b }
> ... hmm, looks ok...

I'm not familiar with quasiquoting, so I wouldn't know.  The interp
part seems fairly straightforward; if $a = 5 and $b = 4, I'd expect
the above to be equivalent to CODE { say 5 + $b }, whatever that
means.

--
Jonathan "Dataweaver" Lang


Re: This weeks summary, part 2

2006-02-19 Thread Ævar Arnfjörð Bjarmason
On 2/18/06, The Perl 6 Summarizer <[EMAIL PROTECTED]> wrote:
>   Smart match table
> Robin Houston had some questions/observations about the smart match
> table in synopsis 4. This is the table that describes how the smart
> match ("~~") operator does its comparisons. It turns out that the table
> in the synopsis implies non-commutative behaviour, which came as
> something of a surprise. I'm surprised this thread petered out so
> quickly without any real resolution; it seems rather important to me.
>
> 

That particular url isn't working.


Re: Selective String Interpolation

2006-02-19 Thread Brad Bowman

On 19/02/06 03:48, Jonathan Lang wrote:

I don't see why you'd need a universal anti-backwhack, any more than
you need universal quote delimiters.  


Here-docs are usually safe to quote any amount of line noise,
but I take your point.


 I could see introducing an
adverb to the quoting mechanism that lets you define a custom
backwhack character in qq strings (for those rare cases where literal
backslashes are common occurrences), and then press the same adverb
into service in q strings to define a custom anti-backwhack.  The only
difference is that there's a default backwhack character (the
backslash), but there is no default anti-backwhack.  So:

  my $code = q:interp(`){
  package `$package_name;

  sub `$sub_name {
  `$the_complex_value_we_want_to_use_in_generated_code
  }

  sub `$another_sub_name {
  [EMAIL PROTECTED](';')}
  }
  };


This would scratch my itch.  The interpolated bits are more visually
distinct than in my by-name proposal, which is a clear advantage. 
(No pun intented)


I don't like the idea of sharing the adverb between escaping and
force-interpolating since stacking other adverbs can turn q into qq
and vice-versa.  That's a minor quibble though.


I'd go so far as to say that the anti-backwhack would only have a
special meaning in front of a $, @, %, {, \, or another
anti-backwhack; in all other cases, it gets treated as a literal
character just like anything else.  There may be some edge conditions
that I haven't thought of; but I think that this is a decent baseline
to work from.


In cases like q:c:interp(`) { ... }, then only `{...} would need a
special meaning.  


The only disadvantage that has occured to me is the complexity
of adding yet another feature.  Syntax highlighters and other
tools would have to handle it.  


I think the Huffman encoding is correct on this, up to and including
the length of the adverb needed to define a custom backwhack or
anti-backwhack.


I agree.  This can be kept in Perl 6's attic most of the time.

Alternatively, it can be a user-defined capability since S06 specifically
allows such tinkering.  Whether to include the feature in basic Perl
depends on the utility-complexity trade off.  I don't have a strong
preference either way, as long as it can be done somehow.

Analogous issues occur with quasiquoting, so a solution that can be 
naturally shared would be ideal.  CODE :interp(`) { say `$a + $b }
... hmm, looks ok...  


Brad

--
After reading books and the like it is best to burn them or throw them away.
   -- Hagakure http://bereft.net/hagakure/