Dashboard > People > Terence Parr > Browse Space > News from
  Terence Parr Log In | Sign Up   View a printable version of the current page.  
  News from Oct 03, 2007
  2007/10/03
Last changed: Oct 03, 2007 14:07 by Terence Parr

Awesome. Mantra does a dynamic mixin. Just map a string to a closure with "self" as first arg:

int.mixin("toHex",
   {int self | return java {new mstring(Integer.toHexString(((mint)self).v))};}
);
println(32.toHex()); // emits 20, the hex verison of 32. :)

also note you could alter the MetaClass per object (set .class field) to alter behavior per instance! You can ask about meta object now:

println(32.class); // emits <int>

To avoid strange bugs, you can only add not override/alter behavior.

Posted at 03 Oct @ 2:04 PM by Terence Parr | 0 comments

October 2007
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Oct 05, 2007
Oct 02, 2007

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators