<div dir="ltr">well it can be made to work with following rule:<div><br></div><div>$ binds as follows, using the 1st pattern matched rule:</div><div><br></div><div>very roughly:</div><div><br></div><div>identifier [$] if typeof(a.length) => a[a.length] //likewise with s/[]/()/</div>
<div>primary_expression . identifier if typeof(primary_expression.length) => primary_expression . identifier [identifier.length] (recursively)</div><div>if no match is found, error.</div><div><br></div><div>eg:</div><div>
<br></div><div>[1,2,3].indexed([0,$-1] ) => indexed.length isn't valid, so it tries to bind to [1,2,3].</div><div><br></div><div>intuitively I believe it makes sense.</div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Oct 31, 2013 at 2:51 AM, Jonathan M Davis <span dir="ltr"><<a href="mailto:jmdavisProg@gmx.com" target="_blank">jmdavisProg@gmx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Thursday, October 31, 2013 02:46:32 Timothee Cour wrote:<br>
> can we support this and similar use cases ?<br>
><br>
> import std.range;<br>
> void main(){<br>
>   auto a=[1,2,3,4];<br>
>   auto b1=a.indexed([0,a.length-1]);//OK<br>
>   auto b2=a.indexed([0,$-1]);//NG<br>
> }<br>
<br>
</div></div>Aren't you creating new arrays to pass to indexed here? If that's the case, $<br>
isn't associated with any particular array, and I don't see how it could work.<br>
<br>
Now, there's issue# 7177<br>
<br>
<a href="http://d.puremagic.com/issues/show_bug.cgi?id=7177" target="_blank">http://d.puremagic.com/issues/show_bug.cgi?id=7177</a><br>
<br>
which aims at getting opDollar to work with ranges which have length (which it<br>
generally doesn't at this point), so that might be related to what you're<br>
looking for, but if what you're looking for is [0, $-1] to work on its own, I<br>
don't see how that could ever work, because $ only works when slicing or<br>
indexing, and [0, $-1] in the context above is an array literal.<br>
<span class="HOEnZb"><font color="#888888"><br>
- Jonathan M Davis<br>
</font></span></blockquote></div><br></div>