On 20/11/2013, at 12:32 PM, srean wrote:
> wait what is this #mk thing ?
Good question with trivial answer:
#f
is exactly the same as
f ()
only the precedence is different (# has a very high precedence, binds very
tightly).
The "mnemonic" reason for this is that
in classes, and other places, one often has constant functions like:
fun pi () => 22.0 / 7.0;
and so you write
#pi
meaning "the constant pi". It will often actually be a constant due to
inlining.
In polymorphic classes there is no choice. You cannot have polymorphic
variables. So you have to use functions for constants. Eg:
class Number[T] {
virtual fun zero ();
...
}
and then you write
#zero[int]
for the "constant".
For mathematical (pure) functions, its always a constant because there's
no variability in the argument. But you can have impure functions too:
var x = 1;
fun g () => x;
println$ #g
++x;
println$ #g;
Anyhow, the answer is "its just a trivial syntax shortcut".
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language