Only a subset of mirrors for dart2js?

240 views
Skip to first unread message

John Evans

unread,
Aug 23, 2012, 9:11:58 AM8/23/12
to mi...@dartlang.org
I borrowed this quote from this thread on G+ by Kasper:

"We are only planning on supporting a subset of the mirror API in dart2js compiled code for now. We are toying with using mirrors at compile time to allow programmatic access to the data structures of the compiler (used by dartdoc and similar tools). We've got lots of ideas but it will take time for things to get implemented."

Can someone please elaborate on how limited this subset will be?  I have a branch of Buckshot that is using quite a bit of introspection and instantiation of classes and fields.  Will this be supported in dart2js (within the same isolate at least)?

Understanding that I am coding against the bleeding-est of the bleeding edge, I have no problems with reverting code back to non-reflective implementations. I'd just like to know how far down the mirrors road I can travel before I cross a boundary that won't be supported by dart2js.

Gilad Bracha

unread,
Aug 23, 2012, 12:20:34 PM8/23/12
to mi...@dartlang.org
I can't commit to anything right now, but AFAIK, the introspection facilities we have at the moment should work with dart2js eventually. You will probably have have to annotate declarations that aren't used by non-reflective code with metadata to prevent them being minified away.

The hard questions come up around mirror builders, where access to a dart compiler might be required for some things - and that is not likely to be there for most apps.




--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
 
 



--
Cheers, Gilad

Gilad Bracha

unread,
Aug 23, 2012, 12:24:52 PM8/23/12
to mi...@dartlang.org
One more thing: timing is up in the air. I suspect that is what Kasper was referring to. So for M1, mirror support may well be absent in dart2js. But I don't know that anything is decided.
--
Cheers, Gilad

John Evans

unread,
Aug 23, 2012, 1:06:25 PM8/23/12
to mi...@dartlang.org
Sorry for the naive question Gilad:  When you are talking about "mirror builders" are you referring to functions that return (via Future) an InstanceMirror, such as ClassMirror.newInstance()?

John Messerly

unread,
Aug 23, 2012, 1:14:19 PM8/23/12
to mi...@dartlang.org
AFAIK, "mirror builders" means building classes/methods/libraries at runtime. In other words, code generation.
Similar in functionality to System.Reflection.Emit in C# if you're familiar with that (but hopefully without the bad, buggy api of Sys.Ref.Emit).

John Evans

unread,
Aug 23, 2012, 1:18:42 PM8/23/12
to mi...@dartlang.org
Ah thanks John.  I thought it was something like .emit(), just wanted to be sure.

So it sounds like, instantiation of known types may make it through to dart2js, although perhaps not right away.

Gilad Bracha

unread,
Aug 23, 2012, 1:28:01 PM8/23/12
to mi...@dartlang.org
On Thu, Aug 23, 2012 at 10:18 AM, John Evans <pru...@gmail.com> wrote:
Ah thanks John.  I thought it was something like .emit(), just wanted to be sure.

So it sounds like, instantiation of known types may make it through to dart2js, although perhaps not right away.


Yes. 
 


On Thursday, August 23, 2012 12:14:19 PM UTC-5, John Messerly wrote:
AFAIK, "mirror builders" means building classes/methods/libraries at runtime.


Yes


--
Cheers, Gilad
Reply all
Reply to author
Forward
0 new messages