Rant after trying Rust a bit
Ziad Hatahet via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 23 14:26:37 PDT 2015
On Thu, Jul 23, 2015 at 2:00 PM, Adam D. Ruppe via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:
> I think it is actually kinda pretty:
What about:
int median(int a, int b, int c) {
return (a<b) ? (b<c) ? b : (a<c) ? c : a : (a<c) ? a : (b<c) ? c : b;
}
vs.
def median(a: Int, b: Int, c: Int) =
if (a < b) {
if (b < c) b
else if (a < c) c
else a
}
else if (a < c) a
else if (b < c) c
else b
Before you get too worried about the (), I'd point out that this is a very
> common pattern in Javascript (for like everything...) and while everybody
> hates JS, most every uses it too; this patten is good enough for usefulness.
>
Is the compiler always able to always optimize out the function call by
inlining it, as would be the case with a scope?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150723/74c38f10/attachment.html>
More information about the Digitalmars-d
mailing list