looking for something akin to as3 metadata

classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|

looking for something akin to as3 metadata

Sam Williams
Hello,

Spent the past day getting very excited about haxe, it's awesome!  I  
am keen to have a go at porting a framework I have built and we use  
use at my company.  The framework is a based on dependency injection  
library (inspired by Google Guice) and relies heavily on metadata +  
reflection, but I cant seem to find any way to attach something like  
metadata (or annotations is Java speak) to my methods/variables etc.  
Any ideas how I could do something that looks like the below  
pseudocode in haxe?

class Wibble
{
     function new(){}

     [Inject]
     function setDependencies( a:IMakeBacon, b:FooMe ):Void
     {
     // ...
     }
}

Cheers
Sam

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

jlm@justinfront.net
Not sure what you mean, but

You can use flek sdk movies in haXe either at runtime or as a library,  
if you look at haxegui you will see they include XML resource files..  
maybe hscript is what you mean by pseudocode in haxe. If you want to  
include visual assets either use a swf as a library and or swfmill.

sorry if I am miles off.

Cheers

;j



On 2 Sep 2009, at 19:37, Samuel Williams wrote:

> Hello,
>
> Spent the past day getting very excited about haxe, it's awesome!  I  
> am keen to have a go at porting a framework I have built and we use  
> use at my company.  The framework is a based on dependency injection  
> library (inspired by Google Guice) and relies heavily on metadata +  
> reflection, but I cant seem to find any way to attach something like  
> metadata (or annotations is Java speak) to my methods/variables  
> etc.  Any ideas how I could do something that looks like the below  
> pseudocode in haxe?
>
> class Wibble
> {
>    function new(){}
>
>    [Inject]
>    function setDependencies( a:IMakeBacon, b:FooMe ):Void
>    {
>    // ...
>    }
> }
>
> Cheers
> Sam
>
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Gustavs

Unfortunately there isn't a good way to add metadata, because the language minds its target platforms. You might instead add static members describing the class somehow.


2009/9/2 Justin Lawerance Mills <[hidden email]>
sorry if I am miles off.


Whoo.
 

On 2 Sep 2009, at 19:37, Samuel Williams wrote:

Hello,

Spent the past day getting very excited about haxe, it's awesome!  I am keen to have a go at porting a framework I have built and we use use at my company.  The framework is a based on dependency injection library (inspired by Google Guice) and relies heavily on metadata + reflection, but I cant seem to find any way to attach something like metadata (or annotations is Java speak) to my methods/variables etc.  Any ideas how I could do something that looks like the below pseudocode in haxe?

class Wibble
{
  function new(){}

  [Inject]
  function setDependencies( a:IMakeBacon, b:FooMe ):Void
  {
  // ...
  }
}

Cheers
Sam

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

gershon
In reply to this post by jlm@justinfront.net
the [embed] \ [inject] thing could be done as preprocessing i guess, maybe using compile-time resource as Justin mentioned.

very short example, wrapped in classes in the haxegui framework:

var xml = Xml.parse('
<var type="Float" value="324.2"/>
<var type="Bool" value="true"/>
');

function useInjected(x:Xml) {
  var a = [];
  for(el in x.elements()) {
   var classname = el.get("type");
   var resolved = Type.resolveClass(classname);
  switch(classname)
    case "Float":
      a.push(Type.createInstace(resolved, [Std.parseFloat(el.get("value")]);
    case "Bool":
      a.push(Type.createInstace(resolved, [el.get("value")==true]);
  }

  trace(a[0]*2);
  trace(a[1]==false);
}

using Type\Reflection and even hscript this can go much further, i think xml is a nice way to wrap the content, hope it helps...

On Wed, Sep 2, 2009 at 9:58 PM, Justin Lawerance Mills <[hidden email]> wrote:
Not sure what you mean, but

You can use flek sdk movies in haXe either at runtime or as a library, if you look at haxegui you will see they include XML resource files.. maybe hscript is what you mean by pseudocode in haxe. If you want to include visual assets either use a swf as a library and or swfmill.

sorry if I am miles off.

Cheers

;j




On 2 Sep 2009, at 19:37, Samuel Williams wrote:

Hello,

Spent the past day getting very excited about haxe, it's awesome!  I am keen to have a go at porting a framework I have built and we use use at my company.  The framework is a based on dependency injection library (inspired by Google Guice) and relies heavily on metadata + reflection, but I cant seem to find any way to attach something like metadata (or annotations is Java speak) to my methods/variables etc.  Any ideas how I could do something that looks like the below pseudocode in haxe?

class Wibble
{
  function new(){}

  [Inject]
  function setDependencies( a:IMakeBacon, b:FooMe ):Void
  {
  // ...
  }
}

Cheers
Sam

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Armén
In reply to this post by Gustavs
Not sure what you mean by "minding target platforms", but if I
understand correctly you are justifying the lack of metadata support
because not all target platforms are able to support the behavior?

IMO "because the language minds its target platforms" is not the real
reason, much less a good one. If true "least common denominator"
approach was used with haXe, true to the farthest extent possible that
is, you would not have flash9.* packages at all, because well, not
target platforms support MovieClip and Sprite natively. Even though
they do  not, haXe still manages to compile SWF files saturated with
calls to the target platform intended. By the same logic, nothing
stops haXe from siding metadata to classes. Just because other
platforms do not support this, does not mean haXe should abstain from
supporting this for the only platform that does.

The real reason is much simpler: it is simply not implemented,
possibly not even planned, as arguably more important things stand in
line to make up a compiler.

On Wed, Sep 2, 2009 at 21:07, Gustavs<[hidden email]> wrote:

>
> Unfortunately there isn't a good way to add metadata, because the language
> minds its target platforms. You might instead add static members describing
> the class somehow.
>
>
> 2009/9/2 Justin Lawerance Mills <[hidden email]>
>>
>> sorry if I am miles off.
>>
>
> Whoo.
>
>>
>> On 2 Sep 2009, at 19:37, Samuel Williams wrote:
>>
>>> Hello,
>>>
>>> Spent the past day getting very excited about haxe, it's awesome!  I am
>>> keen to have a go at porting a framework I have built and we use use at my
>>> company.  The framework is a based on dependency injection library (inspired
>>> by Google Guice) and relies heavily on metadata + reflection, but I cant
>>> seem to find any way to attach something like metadata (or annotations is
>>> Java speak) to my methods/variables etc.  Any ideas how I could do something
>>> that looks like the below pseudocode in haxe?
>>>
>>> class Wibble
>>> {
>>>   function new(){}
>>>
>>>   [Inject]
>>>   function setDependencies( a:IMakeBacon, b:FooMe ):Void
>>>   {
>>>   // ...
>>>   }
>>> }
>>>
>>> Cheers
>>> Sam
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Sam Williams
Wow, thanks for the responses!

I think I can glean that the language does not currently support some kind of metadata construct, that is a shame given what I was trying todo.  Though there are countless other things about the language which are clearly far superior to actionscript, so its still a full on WIN.

Looking forward, it would be good to see a metadata construct making it into the language, as there are countless examples in actionscript and Java where some really powerful and productive things have been done with them. JPA, Guice, AspectJ, Dawn (thats my framework, bit cheeky to add it to the list really, hehe)... an exhaustive list would be huge.

Understand there are probably far more important things on the cards... is there a system for language feature requests? Something like Pythons PEP system?

Cheers for the responses



2009/9/2 [hidden email] <[hidden email]>
Not sure what you mean by "minding target platforms", but if I
understand correctly you are justifying the lack of metadata support
because not all target platforms are able to support the behavior?

IMO "because the language minds its target platforms" is not the real
reason, much less a good one. If true "least common denominator"
approach was used with haXe, true to the farthest extent possible that
is, you would not have flash9.* packages at all, because well, not
target platforms support MovieClip and Sprite natively. Even though
they do  not, haXe still manages to compile SWF files saturated with
calls to the target platform intended. By the same logic, nothing
stops haXe from siding metadata to classes. Just because other
platforms do not support this, does not mean haXe should abstain from
supporting this for the only platform that does.

The real reason is much simpler: it is simply not implemented,
possibly not even planned, as arguably more important things stand in
line to make up a compiler.

On Wed, Sep 2, 2009 at 21:07, Gustavs<[hidden email]> wrote:
>
> Unfortunately there isn't a good way to add metadata, because the language
> minds its target platforms. You might instead add static members describing
> the class somehow.
>
>
> 2009/9/2 Justin Lawerance Mills <[hidden email]>
>>
>> sorry if I am miles off.
>>
>
> Whoo.
>
>>
>> On 2 Sep 2009, at 19:37, Samuel Williams wrote:
>>
>>> Hello,
>>>
>>> Spent the past day getting very excited about haxe, it's awesome!  I am
>>> keen to have a go at porting a framework I have built and we use use at my
>>> company.  The framework is a based on dependency injection library (inspired
>>> by Google Guice) and relies heavily on metadata + reflection, but I cant
>>> seem to find any way to attach something like metadata (or annotations is
>>> Java speak) to my methods/variables etc.  Any ideas how I could do something
>>> that looks like the below pseudocode in haxe?
>>>
>>> class Wibble
>>> {
>>>   function new(){}
>>>
>>>   [Inject]
>>>   function setDependencies( a:IMakeBacon, b:FooMe ):Void
>>>   {
>>>   // ...
>>>   }
>>> }
>>>
>>> Cheers
>>> Sam
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Sam Williams
In reply to this post by gershon


2009/9/2 gershon <[hidden email]>
the [embed] \ [inject] thing could be done as preprocessing i guess, maybe using compile-time resource as Justin mentioned.

very short example, wrapped in classes in the haxegui framework:

var xml = Xml.parse('
<var type="Float" value="324.2"/>
<var type="Bool" value="true"/>
');

function useInjected(x:Xml) {
  var a = [];
  for(el in x.elements()) {
   var classname = el.get("type");
   var resolved = Type.resolveClass(classname);
  switch(classname)
    case "Float":
      a.push(Type.createInstace(resolved, [Std.parseFloat(el.get("value")]);
    case "Bool":
      a.push(Type.createInstace(resolved, [el.get("value")==true]);
  }

  trace(a[0]*2);
  trace(a[1]==false);
}

using Type\Reflection and even hscript this can go much further, i think xml is a nice way to wrap the content, hope it helps...


The nice thing about metadata is it doesn't require the additional xml files (not a big fan of xml), and I think to achieve DI à la Google Guice the xml would have to be quite verbose, when one of the nice things about metadata driven injections is they are both terse and type safe.

Neat idea though

 

On Wed, Sep 2, 2009 at 9:58 PM, Justin Lawerance Mills <[hidden email]> wrote:
Not sure what you mean, but

You can use flek sdk movies in haXe either at runtime or as a library, if you look at haxegui you will see they include XML resource files.. maybe hscript is what you mean by pseudocode in haxe. If you want to include visual assets either use a swf as a library and or swfmill.

sorry if I am miles off.

Cheers

;j




On 2 Sep 2009, at 19:37, Samuel Williams wrote:

Hello,

Spent the past day getting very excited about haxe, it's awesome!  I am keen to have a go at porting a framework I have built and we use use at my company.  The framework is a based on dependency injection library (inspired by Google Guice) and relies heavily on metadata + reflection, but I cant seem to find any way to attach something like metadata (or annotations is Java speak) to my methods/variables etc.  Any ideas how I could do something that looks like the below pseudocode in haxe?

class Wibble
{
  function new(){}

  [Inject]
  function setDependencies( a:IMakeBacon, b:FooMe ):Void
  {
  // ...
  }
}

Cheers
Sam

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Danny Wilson
In reply to this post by Sam Williams
Not so fast!

Use RTTI:
  http://haxe.org/api/haxe/rtti/infos
  http://haxe.org/doc/advanced/rtti


interface Injectable implements haxe.rtti.Infos
{} // Stub interface just to make things more explicit


class Wibble implements Injectable
{
    function new( a:IMakeBacon, b:FooMe )
    {
     ...
    }
}

Now your dependency resolver  could look at what parameters  new Wibble  
takes, when you pass the class.

class WibbleModule
{
  function configure() {
    bind(Wibble,  WibbleImplementation);
    // bind looks at the given classes and what their  new parameters
are (the dependencies)
  }
}

var di = new Injector(new WibbleModule());


di.instantiate(Wibble);
// instantiate() looks at what Wibble was bound to and calls  
Type.createInstance  with the required dependencies.


Good luck ;-)


Sam Williams wrote:

> Wow, thanks for the responses!
>
> I think I can glean that the language does not currently support some
> kind of metadata construct, that is a shame given what I was trying
> todo.  Though there are countless other things about
> the language which are clearly far superior to actionscript, so its
> still a full on WIN.
>
> Looking forward, it would be good to see a metadata construct making
> it into the language, as there are countless examples in actionscript
> and Java where some really powerful and productive things have been
> done with them. JPA, Guice, AspectJ, Dawn (thats my framework, bit
> cheeky to add it to the list really, hehe)... an exhaustive list would
> be huge.
>
> Understand there are probably far more important things on the
> cards... is there a system for language feature requests? Something
> like Pythons PEP system?
>
> Cheers for the responses
>
>
>
> 2009/9/2 [hidden email] <mailto:[hidden email]>
> <[hidden email] <mailto:[hidden email]>>
>
>     Not sure what you mean by "minding target platforms", but if I
>     understand correctly you are justifying the lack of metadata support
>     because not all target platforms are able to support the behavior?
>
>     IMO "because the language minds its target platforms" is not the real
>     reason, much less a good one. If true "least common denominator"
>     approach was used with haXe, true to the farthest extent possible that
>     is, you would not have flash9.* packages at all, because well, not
>     target platforms support MovieClip and Sprite natively. Even though
>     they do  not, haXe still manages to compile SWF files saturated with
>     calls to the target platform intended. By the same logic, nothing
>     stops haXe from siding metadata to classes. Just because other
>     platforms do not support this, does not mean haXe should abstain from
>     supporting this for the only platform that does.
>
>     The real reason is much simpler: it is simply not implemented,
>     possibly not even planned, as arguably more important things stand in
>     line to make up a compiler.
>
>     On Wed, Sep 2, 2009 at 21:07, Gustavs<[hidden email]
>     <mailto:[hidden email]>> wrote:
>     >
>     > Unfortunately there isn't a good way to add metadata, because
>     the language
>     > minds its target platforms. You might instead add static members
>     describing
>     > the class somehow.
>     >
>     >
>     > 2009/9/2 Justin Lawerance Mills <[hidden email]
>     <mailto:[hidden email]>>
>     >>
>     >> sorry if I am miles off.
>     >>
>     >
>     > Whoo.
>     >
>     >>
>     >> On 2 Sep 2009, at 19:37, Samuel Williams wrote:
>     >>
>     >>> Hello,
>     >>>
>     >>> Spent the past day getting very excited about haxe, it's
>     awesome!  I am
>     >>> keen to have a go at porting a framework I have built and we
>     use use at my
>     >>> company.  The framework is a based on dependency injection
>     library (inspired
>     >>> by Google Guice) and relies heavily on metadata + reflection,
>     but I cant
>     >>> seem to find any way to attach something like metadata (or
>     annotations is
>     >>> Java speak) to my methods/variables etc.  Any ideas how I
>     could do something
>     >>> that looks like the below pseudocode in haxe?
>     >>>
>     >>> class Wibble
>     >>> {
>     >>>   function new(){}
>     >>>
>     >>>   [Inject]
>     >>>   function setDependencies( a:IMakeBacon, b:FooMe ):Void
>     >>>   {
>     >>>   // ...
>     >>>   }
>     >>> }
>     >>>
>     >>> Cheers
>     >>> Sam
>     >>>
>     >>> --
>     >>> haXe - an open source web programming language
>     >>> http://haxe.org
>     >>
>     >>
>     >> --
>     >> haXe - an open source web programming language
>     >> http://haxe.org
>     >
>     >
>     > --
>     > haXe - an open source web programming language
>     > http://haxe.org
>     >
>
>     --
>     haXe - an open source web programming language
>     http://haxe.org
>
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Franco Ponticelli
Following Danny suggestion you can also use RTTI to take useful infos out of the documentation that is attached to a class or field.
So in a ORM context you could do something like:

/**
* @table TBL_USERS
*/
class User implements haxe.rtti.Infos { ... }

I have done that before so I know it works. I hope I can blog about it soon ;)

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Justin Donaldson
I'd sure like to hear more about it.  Especially the efficiency trade-offs involved.

Best,
-Justin

On Wed, Sep 2, 2009 at 5:30 PM, Franco Ponticelli <[hidden email]> wrote:
Following Danny suggestion you can also use RTTI to take useful infos out of the documentation that is attached to a class or field.
So in a ORM context you could do something like:

/**
* @table TBL_USERS
*/
class User implements haxe.rtti.Infos { ... }

I have done that before so I know it works. I hope I can blog about it soon ;)

Franco

--
haXe - an open source web programming language
http://haxe.org



--
Justin Donaldson
PhD Candidate, Informatics
Indiana University
http://www.scwn.net
aim: iujjd
twitter: jjdonald

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Sam Williams
In reply to this post by Franco Ponticelli
Awesome! This looks like exactly what I am after!!

Have just built a Guice port for as3 (http://wiki.github.com/sammyt/dawn)... think I know what I'll be doing this weekend!  :)

Sammy


2009/9/2 Franco Ponticelli <[hidden email]>
Following Danny suggestion you can also use RTTI to take useful infos out of the documentation that is attached to a class or field.
So in a ORM context you could do something like:

/**
* @table TBL_USERS
*/
class User implements haxe.rtti.Infos { ... }

I have done that before so I know it works. I hope I can blog about it soon ;)

Franco

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Sam Williams
Incase anyones following this, if you want to access documentation via rtti you need to add the following arg to your build.hxml (well I had to anyway)
-D use_rtti_doc
Sam



2009/9/2 Sam Williams <[hidden email]>
Awesome! This looks like exactly what I am after!!

Have just built a Guice port for as3 (http://wiki.github.com/sammyt/dawn)... think I know what I'll be doing this weekend!  :)

Sammy


2009/9/2 Franco Ponticelli <[hidden email]>
Following Danny suggestion you can also use RTTI to take useful infos out of the documentation that is attached to a class or field.
So in a ORM context you could do something like:

/**
* @table TBL_USERS
*/
class User implements haxe.rtti.Infos { ... }

I have done that before so I know it works. I hope I can blog about it soon ;)

Franco

--
haXe - an open source web programming language
http://haxe.org



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Gustavs
In reply to this post by Armén

2009/9/2 [hidden email] <[hidden email]>
IMO "because the language minds its target platforms" is not the real
reason, much less a good one. If true "least common denominator"
approach was used with haXe, true to the farthest extent possible that
is, you would not have flash9.* packages at all, because well, not
target platforms support MovieClip and Sprite natively. Even though
they do  not, haXe still manages to compile SWF files saturated with
calls to the target platform intended. By the same logic, nothing
stops haXe from siding metadata to classes. Just because other
platforms do not support this, does not mean haXe should abstain from
supporting this for the only platform that does.

flash9 is the direct API of the AS3 platform. As you should be aware, haXe targets multiple platforms and thus makes different APIs available depending on the compilation target specified. I think there is an obvious difference between platform API and general features of the language.
 

On Wed, Sep 2, 2009 at 21:07, Gustavs<[hidden email]> wrote:
>
> Unfortunately there isn't a good way to add metadata, because the language
> minds its target platforms. You might instead add static members describing
> the class somehow.
>
>
> 2009/9/2 Justin Lawerance Mills <[hidden email]>
>>
>> sorry if I am miles off.
>>
>
> Whoo.
>
>>
>> On 2 Sep 2009, at 19:37, Samuel Williams wrote:
>>
>>> Hello,
>>>
>>> Spent the past day getting very excited about haxe, it's awesome!  I am
>>> keen to have a go at porting a framework I have built and we use use at my
>>> company.  The framework is a based on dependency injection library (inspired
>>> by Google Guice) and relies heavily on metadata + reflection, but I cant
>>> seem to find any way to attach something like metadata (or annotations is
>>> Java speak) to my methods/variables etc.  Any ideas how I could do something
>>> that looks like the below pseudocode in haxe?
>>>
>>> class Wibble
>>> {
>>>   function new(){}
>>>
>>>   [Inject]
>>>   function setDependencies( a:IMakeBacon, b:FooMe ):Void
>>>   {
>>>   // ...
>>>   }
>>> }
>>>
>>> Cheers
>>> Sam
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Armén
On Thu, Sep 3, 2009 at 16:51, Gustavs<[hidden email]> wrote:

>
> 2009/9/2 [hidden email] <[hidden email]>
>>
>> IMO "because the language minds its target platforms" is not the real
>> reason, much less a good one. If true "least common denominator"
>> approach was used with haXe, true to the farthest extent possible that
>> is, you would not have flash9.* packages at all, because well, not
>> target platforms support MovieClip and Sprite natively. Even though
>> they do  not, haXe still manages to compile SWF files saturated with
>> calls to the target platform intended. By the same logic, nothing
>> stops haXe from siding metadata to classes. Just because other
>> platforms do not support this, does not mean haXe should abstain from
>> supporting this for the only platform that does.
>
> flash9 is the direct API of the AS3 platform. As you should be aware, haXe
> targets multiple platforms and thus makes different APIs available depending
> on the compilation target specified. I think there is an obvious difference
> between platform API and general features of the language.
>

I meant to illustrate how we sometimes think in too rigid borders,
which limit us, instead of acknowledging that something is very
doable. Certainly, the difference is obvious, but at the same time,
the compiler does not care whether it is the API or the syntax that
are compatible or not compatible with a certain platform. That was
what I was trying to say. In the same way that haXe complains when you
try to create a MovieClip with JavaScript target, it can complain when
you try to compile metadata to a target that does not support it.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Gustavs

2009/9/3 [hidden email] <[hidden email]>

I meant to illustrate how we sometimes think in too rigid borders,
which limit us, instead of acknowledging that something is very
doable. Certainly, the difference is obvious, but at the same time,
the compiler does not care whether it is the API or the syntax that
are compatible or not compatible with a certain platform. That was
what I was trying to say. In the same way that haXe complains when you
try to create a MovieClip with JavaScript target, it can complain when
you try to compile metadata to a target that does not support it.

That's an option, but so far the language has been designed to support its general features on all platforms, that also being used as an argument by Nicolas to dismiss some suggestions. Which is why I said originally that the language minds compatibility to keep cross-platform code such.

Although of course, adding a metatag syntax for extra sugar could be discussed.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Tony Polinelli
There is a difference between language features and target api +
libraries. You say that MovieClip only exists on the flash target.
This is true, but the MovieClip class is a part of the flash api, and
isnt a language feature.

It shouldnt be expected that all api's are crossplatform. All language
features are however - and what you do with them is your own choice.
If you create crossplatform code.. then great. For example,
neash.display.MovieClip shows how the MovieClip + the rest of the
flash.* package can exist in a crossplatform sense.


On Fri, Sep 4, 2009 at 5:20 AM, Gustavs<[hidden email]> wrote:

>
> 2009/9/3 [hidden email] <[hidden email]>
>>
>> I meant to illustrate how we sometimes think in too rigid borders,
>> which limit us, instead of acknowledging that something is very
>> doable. Certainly, the difference is obvious, but at the same time,
>> the compiler does not care whether it is the API or the syntax that
>> are compatible or not compatible with a certain platform. That was
>> what I was trying to say. In the same way that haXe complains when you
>> try to create a MovieClip with JavaScript target, it can complain when
>> you try to compile metadata to a target that does not support it.
>
> That's an option, but so far the language has been designed to support its
> general features on all platforms, that also being used as an argument by
> Nicolas to dismiss some suggestions. Which is why I said originally that the
> language minds compatibility to keep cross-platform code such.
>
> Although of course, adding a metatag syntax for extra sugar could be
> discussed.
>
> --
> haXe - an open source web programming language
> http://haxe.org
>



--
Tony Polinelli
http://touchmypixel.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Gamehaxe
I think it is reasonable do do something for 1 platform,
but do it on a way that could potentailly be used by other targets.

If the meta-data were to appear in the compiler's abstract-syntax-tree
and simply get ignored by platforms that do not support it, then
it would allow for some interesting possibilities in back end design.


eg, imagine if you could specify "implemented_with = some_file.cpp"
in the meta-data, telling c++ backend to link in an additional file
when the class is used.  I'm sure there are other uses for getting
backend specific info into a class definition, which can be ignored
by platforms that do to support it.

Another example is "swf-header".  Now I would like to access this
for neko/neash back end too, but can't.  However if there were
a way of specifying this as meta-data for the class, and then
accessing this from withing the code (eg, some virtual static variable)
then it would be a good thing all around.

Another solution may to be invert the problem - allow specially ("magic")
named static variables to compile into flash meta-data.  eg.

class XXX
{
    static var _flash_stage_width = 120;
    static var _flash_stage_height = 120;
    static var _flash_stage_framerate = 20;
    static var _flash_stage_background_color = 0xff0000;
}

compare to:

  -swfheader 120:120:ff0000:20

The flash backend would find these variables by name.
(And the neko backend could use these directly)

Hugh

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Armén
In reply to this post by Tony Polinelli
On Fri, Sep 4, 2009 at 01:12, Tony Polinelli<[hidden email]> wrote:

> There is a difference between language features and target api +
> libraries. You say that MovieClip only exists on the flash target.
> This is true, but the MovieClip class is a part of the flash api, and
> isnt a language feature.
>
> It shouldnt be expected that all api's are crossplatform. All language
> features are however - and what you do with them is your own choice.
> If you create crossplatform code.. then great. For example,
> neash.display.MovieClip shows how the MovieClip + the rest of the
> flash.* package can exist in a crossplatform sense.
>

But why is it then expected that all syntax has to be cross-platform?
After all, if you don't use particular would-be non-cross-platform
syntax features, your syntax IS cross-platform, is it not?

Also, even though MovieClip class exists in neash and flash, they
respectively are part of two different packages, which again makes the
code non-cross-platform, because the "import" line, if there is one or
the full classpath will compile on one but not the other platform. So,
in a sense, even API is difficult to make platform transparent. Part
of my point was, while we are so far off the mark, why not put in
metadata support, and be done with IMO not necessarily strictly
applicable excuses.

Cheers.

>
> On Fri, Sep 4, 2009 at 5:20 AM, Gustavs<[hidden email]> wrote:
>>
>> 2009/9/3 [hidden email] <[hidden email]>
>>>
>>> I meant to illustrate how we sometimes think in too rigid borders,
>>> which limit us, instead of acknowledging that something is very
>>> doable. Certainly, the difference is obvious, but at the same time,
>>> the compiler does not care whether it is the API or the syntax that
>>> are compatible or not compatible with a certain platform. That was
>>> what I was trying to say. In the same way that haXe complains when you
>>> try to create a MovieClip with JavaScript target, it can complain when
>>> you try to compile metadata to a target that does not support it.
>>
>> That's an option, but so far the language has been designed to support its
>> general features on all platforms, that also being used as an argument by
>> Nicolas to dismiss some suggestions. Which is why I said originally that the
>> language minds compatibility to keep cross-platform code such.
>>
>> Although of course, adding a metatag syntax for extra sugar could be
>> discussed.
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>
>
>
> --
> Tony Polinelli
> http://touchmypixel.com
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Franco Ponticelli

But why is it then expected that all syntax has to be cross-platform?

Because this is a really sane thing to do. API is API, language is language ...
 
After all, if you don't use particular would-be non-cross-platform
syntax features, your syntax IS cross-platform, is it not?

Adding syntax specific things for targets will confuse people that want to switch from one platform to another. The exageration of this point is that each target will have its own language which is basically what haXe wants to avoid. Reinforcing on it, if you want Flash why not using AS3 direcly, or Javascript for Javascript? They are already mature languages ... the point in haxe is to try to unify as far as possible.
 
Also, even though MovieClip class exists in neash and flash, they
respectively are part of two different packages, which again makes the
code non-cross-platform, because the "import" line, if there is one or
the full classpath will compile on one but not the other platform. So,
in a sense, even API is difficult to make platform transparent.

You miss a point here. Packages can be unified using aliases in the command line, so that flash or neash can be the same.
 
Part of my point was, while we are so far off the mark, why not put in
metadata support, and be done with IMO not necessarily strictly
applicable excuses.

You call them excuses, I call them reasons. I'd like to have metadata support but only if I can leverage them on all the platform. Obviously those metadata could have different purposes on different targets but anyway they should be consistent from the start.

Franco.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: looking for something akin to as3 metadata

Heinz Hölzer-2
Good Point, I think Crossplatform is the only good solution and it could
be implemented just like the rtti implementation as a static class field
(maybe __metadata), with an Api to access them.




Franco Ponticelli schrieb:

>
>     But why is it then expected that all syntax has to be cross-platform?
>
>
> Because this is a really sane thing to do. API is API, language is
> language ...
>  
>
>     After all, if you don't use particular would-be non-cross-platform
>     syntax features, your syntax IS cross-platform, is it not?
>
>
> Adding syntax specific things for targets will confuse people that
> want to switch from one platform to another. The exageration of this
> point is that each target will have its own language which is
> basically what haXe wants to avoid. Reinforcing on it, if you want
> Flash why not using AS3 direcly, or Javascript for Javascript? They
> are already mature languages ... the point in haxe is to try to unify
> as far as possible.
>  
>
>     Also, even though MovieClip class exists in neash and flash, they
>     respectively are part of two different packages, which again makes the
>     code non-cross-platform, because the "import" line, if there is one or
>     the full classpath will compile on one but not the other platform. So,
>     in a sense, even API is difficult to make platform transparent.
>
>
> You miss a point here. Packages can be unified using aliases in the
> command line, so that flash or neash can be the same.
>  
>
>     Part of my point was, while we are so far off the mark, why not put in
>     metadata support, and be done with IMO not necessarily strictly
>     applicable excuses.
>
>
> You call them excuses, I call them reasons. I'd like to have metadata
> support but only if I can leverage them on all the platform. Obviously
> those metadata could have different purposes on different targets but
> anyway they should be consistent from the start.
>
> Franco.


--
haXe - an open source web programming language
http://haxe.org
12