D-etractions A real world programmers view on D

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Wed Sep 5 11:22:43 PDT 2012


On Wed, 05 Sep 2012 08:34:34 +0200
Jacob Carlborg <doob at me.com> wrote:
> 
> When I said "dynamic typing" that was a bit misleading. It's more the 
> dynamic nature of Ruby I like. For example:
> 
> * Open classes
> * Reflection - adding methods, calling a method via a string,
> introspection

As far as monkey patching, I find *not* having that to be a major
feature. :)

While a lot of runtime reflection *can* be built in D (even if it
isn't all there right now), I am kind of annoyed at some of the
limitations. Like how it's impossible (at either compile-time or
runtime) to find the subclasses of a class. Uhh, actually that's the
only limitation I know of. There might be more though.

> * Have executing code in all level of scopes

Not sure what sure mean by this?

> * Eval
> 

Needs polish, but:

https://bitbucket.org/Abscissa/semitwistdtools/src/977820d5dcb0/src/semitwist/util/process.d#cl-49

Usage:

string str;

str = q{ return 42; };
assert( eval!int(str) == 42 );

str = q{ return "Test string".dup; };
assert( eval!(char[])(str) == "Test string" );

:)

Granted, there'd probably be a lot less overhead doing that in Ruby or
JS. But it works, more or less.



More information about the Digitalmars-d mailing list