> On 21 Dec 2015, at 18:06, Zefram <zef...@fysh.org> wrote:
> Elizabeth Mattijsen via RT wrote:
>> There is a subtle difference between Str.perl and
>> Rakudo::Internals.PERLIFY-STR:  The former puts double quotes around, the
>> latter doesn't.
> 
> Yes, hence the doubling when you call the former and also wrap the result
> in quotes.
> 
>> I'm afraid we'll have to settle for poor factoring.
> 
> What?  You need to call .perl and *not* put an extra layer of quotes
> around the result.  What's the difficulty?  You managed to do it for
> $!SPEC in IO::Path.perl.
> 
>    multi method perl(CompUnit::Repository::Locally:D:) {
>       "{$?CLASS.^name}.new({$!prefix.abspath.perl})"
>    }
> 
>    multi method perl(IO::Local:D:) { "{$!abspath.perl}.IO" }
> 
>    multi method perl(IO::Path:D:) {
>       $!is-absolute
>           ?? "{$.abspath.perl}.IO(:SPEC({$!SPEC.perl}))"
>           !! "{$.path.perl}.IO(:SPEC({$!SPEC.perl}),:CWD({$!CWD.perl}))"
>    }
> 
> Further factoring win is available by taking advanage of Pair.perl.
> Aside from just being less code, it also gets you potential future
> wins if Pair.perl later gets clever enough to use :foo<bar> syntax.
> I showed how to factor this in a previous message on [perl #126935]:
> 
>    multi method perl(IO::Path:D:) {
>       $!is-absolute
>           ?? "{$.abspath.perl}.IO({:$!SPEC.perl})"
>           !! "{$.path.perl}.IO({:$!SPEC.perl},{:$!CWD.perl})"
>    }
> 
> The same should really be done with $?CLASS, in case class deparsing
> gets cleverer about name scoping in the future:
> 
>    multi method perl(CompUnit::Repository::Locally:D:) {
>       "{$?CLASS.perl}.new({$!prefix.abspath.perl})"
>    }

All of that goodness now in 591783d116a56d4b2c54f .


> hen writing a pervasive value deparsing system, such as .perl is intended
> to be, a great convenience is that one of the tools available to you is
> a pervasive value deparsing system (for all types other than whichever
> one you're working on right now).  So you don't have to do the whole
> deparsing job yourself, and in fact you get better results by doing less
> of the work yourself.

Indeed!   Now, if this had been in a Pull Request, I could have just clicked on 
Merge, which would have been less work for me  :-)

Ever considered getting a commit bit ?



Liz

Reply via email to