Whar is purpose of Symbol type?It is "Opaque name used by mirrors, invocations and Function.apply".It's all?
The discussion only about Dart Symbol type.1. What are real purpose?
2. Will be added new built-in type or not?
>> There are only literals for some of the classes in dart:core.
Sorry, but you're talking about things that you do not understand.
>> Sorry, but you're being a bit rude to him. :)
I highly respect him. Honest.Ladislav, my friend, I'm sorry. You're doing fine.
>> Sorry, but you're being a bit rude to him. :)
I highly respect him. Honest.Ladislav, my friend, I'm sorry. You're doing fine.
I expect this will be discussed in future language meetings.
--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
> In the red corner: the mirror API will be horrible to use without literal syntax for symbols.
>
> In the blue corner: the mirror API, although important, is just one library amongst many
It's the only way we can do meta-programming, no? I think that this qualifies mirrors a little above the other libraries.
> Unless symbols are used pervasively throughout general Dart programs, literal syntax seems excessive.
Can we translate this to "unless meta-programming is used pervasively throughout general Dart programs, ..."?
LT
Nice summation.
How many users of symbols do you expect? Only debuggers and such?
In the green corner, perhaps that horrible map syntax to make a symbol map points to a shortfall in map literals in general. I'd pay for a cleaner way to make general map literals, and all literals.
I'd call that a good translation. And as 1data point, I don't meta-program or reflect every day. I only rarely do those things.
--
LT
Why situation should be different for other enums? If we introduce literal #foo for const Symbol("foo"), why literal #Green cannot play the same role in other enumerations as #foo plays in mirrors?
>> because Symbol foo will be interpreted in a context of A or B anyway, depending on invocation.
I don't understand.Symbols captured the context when them instantiated?I.e. symbols with the same signature but created in different places will be diffirent?Which information them captured on instantiation?Information about library, class and method?What happened if symbol wil be passed incorrectly?Which error handling will be provided for this situations?Or will it be on the conscience of a programmer?
I apologize for such questions. It is not rude. I just want to understand the meaning.
E.g. somebody said the map is not transferred to client. Then... how it works when, like in mezoni's example, somebody tries to create Symbol on client : new Symbol(str). System certainly should look it up in a map of some kind, right?
Dart is not pure object oreiented programming language.
Class in dart is object of class Class (or object of other class)?Library in dart is object of class Library (or object of other class)?
>> That's a leading principle behind metaprogramming in Dart -- it's completely separated from base level.
You are mistaken.At the moment the Dart is not a metaprogramming language because no one main principle of Metaprogramming can be found in Dart.
1. Dart does not support evaluating expression at runtime (eval).
What are symbols in Dart?From Dart API reference guide: http://api.dartlang.org/docs/releases/latest/dart_core/Symbol.htmlSymbol class
Opaque name used by mirrors, invocations and Function.apply.
I.e. the folllowing statements is true.1. Symbol is not the built-in type.2. Symbol is the classified type.
Whar is purpose of Symbol type?It is "Opaque name used by mirrors, invocations and Function.apply".It's all?
Or there something else?-----------------From Ruby language.What are symbols?It's a string. No it's an object. No it's a name.A Ruby symbol is a thing that has both a number (integer) representation and a string representation.What are symbols not?A Symbol is Not a String.And so on...-----------------There is already a proposal in Dart for the introduction of separate presentation for the values of Symbol type.Like this (`foo`) or (#foo).In other words, the proposal to introduce a new built-in type in the grammar of the language.
Ladislav, please, answer me.Dart is class-based language and object oriented.1. Object is an instance of class?
2. What means term "class" in Dart?
3. Where classes stored?4. How classes can be obtained and used in Dart?
5. What means object of class XXX?
---------------From Type in dart:coreType abstract classRuntime representation of a type.I.e. Abstract class type is runtime representation of a type (another type that not runtime).The documentation is not sufficient.I don't know what means "another type that not runtime" which Abstract class type represent at runtime.---------------TypeMirror abstract classA TypeMirror reflects a Dart language class, typedef, or type variable.Well. A TypeMirror reflects a Dart language class.May be you explain me what is a Dart language class?Or may be you explain me what is a class in Dart language?Or may be simple? What is a class?With you are all clear.1. Class is something that reflects TypeMirror.2. A TypeMirror reflects a Dart language class.What is a class?See #1.---------------Abraham, where you take the money?In a box.And in a box where they come from?Wife puts them there.And the wife where takes money?I give her.Where do you get the money?In a box.And in a box where they come from?Wife puts them there....
> How TypeMirror or ClassMirror acn reflects on something that in reality does not exist?
It's this simple: it DOES exist (both as a concept in the language specification and as an object in Dart implementation), but you can't access it directly. You can only interact with it using its mirror.
So yes, this is more similar to Java than to SmallTalk, but there are obvious reasons: performance, safety and good engineering practice.
> Mirror involves reflection.
> If you go to the mirror you see your reflection.
>
> What reflects TypeMirror or ClassMirror?
> Ghost? Vampire?
They are normal objects of normal classes, so you can reflect on them using normal reflection. Therefore, if you have an object of class ClassMirror and you reflect on it, you will get an InstanceMirror, which of course has its own ClassMirror.
> Where is the source of reflection?
God. Or the laws of physics. Or, tadaa, the dart:mirrors library. It isn't in the language, it's completely defined by the library -- which is also why you can completely forbid reflection, if you embed the Dart VM in your own program. (Yes, you can do that, and yes, it can be useful.)
LT
P.S.: what exactly are you trying to prove here? The fact that Dart isn't SmallTalk? We all know that.
> How TypeMirror or ClassMirror acn reflects on something that in reality does not exist?It's this simple: it DOES exist (both as a concept in the language specification and as an object in Dart implementation), but you can't access it directly. You can only interact with it using its mirror.
So yes, this is more similar to Java than to SmallTalk, but there are obvious reasons: performance, safety and good engineering practice.
> Mirror involves reflection.
> If you go to the mirror you see your reflection.
>
> What reflects TypeMirror or ClassMirror?
> Ghost? Vampire?They are normal objects of normal classes, so you can reflect on them using normal reflection. Therefore, if you have an object of class ClassMirror and you reflect on it, you will get an InstanceMirror, which of course has its own ClassMirror.
> Where is the source of reflection?
God. Or the laws of physics. Or, tadaa, the dart:mirrors library. It isn't in the language, it's completely defined by the library -- which is also why you can completely forbid reflection, if you embed the Dart VM in your own program. (Yes, you can do that, and yes, it can be useful.)
LT
P.S.: what exactly are you trying to prove here? The fact that Dart isn't SmallTalk? We all know that.
--
> How TypeMirror or ClassMirror acn reflects on something that in reality does not exist?
It's this simple: it DOES exist (both as a concept in the language specification and as an object in Dart implementation), but you can't access it directly. You can only interact with it using its mirror.
So yes, this is more similar to Java than to SmallTalk, but there are obvious reasons: performance, safety and good engineering practice.
Actually, Smalltalk (notice proper case :-)
and Java made the same mistakes when it comes to reflection. Dart is more similar to Self than it is to Java in this case.
See Gilad's paper on this topic: http://bracha.org/mirrors.pdf
> How TypeMirror or ClassMirror acn reflects on something that in reality does not exist?
It's this simple: it DOES exist (both as a concept in the language specification and as an object in Dart implementation), but you can't access it directly. You can only interact with it using its mirror.
So yes, this is more similar to Java than to SmallTalk, but there are obvious reasons: performance, safety and good engineering practice.
Actually, Smalltalk (notice proper case :-)Doh! Sorry, guys :-)and Java made the same mistakes when it comes to reflection. Dart is more similar to Self than it is to Java in this case.See Gilad's paper on this topic: http://bracha.org/mirrors.pdfYou're speaking about the main principles behind mirrors, right? The fact that meta-level is separated from base-level and such.
I was speaking more about the fact than in Java, you only get a reflective access to the class (a very limited one, that is), while in Smalltalk, classes are normal objects. Which seems to be what this thread is all about.
But thanks for your insight. It's always appreciated -- my understanding is severely limited in this area :-)LT
--
>> Unlike Java, Dart has no values that aren't objects.>> In Dart, even classes are objects, but their implementation details are hidden and can only be examined through the mirror system.
A small correction.Type (not a class) implementation details are hidden and can only be examined through the mirror system.In the Dart runtime there is no classes (nor hidden nor visible).Only types.Classes in Dart only the form and behavior of a set of objects which are its instances.Also, I do not argue reflestion is present.P.S.How implemented _Type (RuntimeType) I would be ashamed to even mention it.It's just a circus.Also name "Symbol" for example, is slightly embarrassing.
"ReflectionLink" are more meaningful.
>> Unlike Java, Dart has no values that aren't objects.>> In Dart, even classes are objects, but their implementation details are hidden and can only be examined through the mirror system.A small correction.Type (not a class) implementation details are hidden and can only be examined through the mirror system.In the Dart runtime there is no classes (nor hidden nor visible).Only types.Classes in Dart only the form and behavior of a set of objects which are its instances.Also, I do not argue reflestion is present.P.S.How implemented _Type (RuntimeType) I would be ashamed to even mention it.It's just a circus.Also name "Symbol" for example, is slightly embarrassing."ReflectionLink" are more meaningful.
--
In Dart, all values are objects. Not all Dart concepts are values.
> Why you post this example?
>
> var f = Foo;
> new f();
> This is impossible. Or it return the same Foo.
>
> But this is possible in other languages.
>
> var stringClass = String;
> var stringValue = stringClass.createInstance('Hello');
var stringClass = String;
var stringValue = reflectClass(stringClass).newInstance(const Symbol(''), ['Hello']);
Well, this doesn't work as the String class doesn't have a copy constructor, but you get the idea.
LT