EVars - Why Is This An Array Of Vars ?

44 views
Skip to first unread message

Arnim Schachtschabel

unread,
Jul 7, 2016, 9:21:18 AM7/7/16
to Haxe

Hello community,

a stupid question besides:

Safe to say:
The    EVar Expression    EVars(vars:Array<Var>)   can be seen as the "moment" of declaring a variable. And each  Var    object holds the type (if explicitely set), the identifier and the expression assign to it (if given).

Why does   EVars  then hold an array of   Var objects?
Why doesn't it simply hold a single   Var  object?

All use-cases I have tested on my own only return one item of that array (as assumed).

I want to be safe not to oversee important use-cases (or maybe even the obvious ;-) ...)

I want to build a code-inspector/ debugger that can show you all important informations available (and also filters them out, if they are not needed).

So, the coverage of possibly occuring cases is supposed not to become incomplete or to be programmed carelessly.

I would be glad, if someone could tell me the purpose/ advantage of that array holding  Var objects.

In the worst case, I could blindly programm the inspector with my own assumptions, trusting that no unexpected behaviour would occur. But that would not be the ideal case.

I am looking forward to your answers.

Kind regards
Arnim

Juraj Kirchheim

unread,
Jul 7, 2016, 9:28:14 AM7/7/16
to haxe...@googlegroups.com
Here's an example: http://try-haxe.mrcdk.com/#94652

That being said, the two consecutive EVars are treated exactly as their combined version.

Best,
Juraj

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Arnim Schachtschabel

unread,
Jul 7, 2016, 10:01:46 AM7/7/16
to Haxe

Ah, that makes sense...

Hello Juraj,

thank you for your reply.

Then this is rather a macro specific use-case?

As I am handling this with a for-loop anyway, this is just a question to enlarge my haxe-horizon...
;-)

Kind regards
Arnim

Juraj Kirchheim

unread,
Jul 7, 2016, 10:25:16 AM7/7/16
to haxe...@googlegroups.com
I wouldn't really call it macro-related. Maybe my example was poorly chosen.

What I mean is that you can write this:

  var a = 2;
  var b = 3;

Or this:

  var a = 2, b = 3;

They are represented differently, but the typer then flattens it (see http://api.haxe.org/haxe/macro/TypedExprDef.html#TVar). That being said, I don't think they should be treated the same and with some luck future Haxe versions might start distinguishing both, because the current state is rather useless syntactic sugar.

Best,
Juraj


Arnim Schachtschabel

unread,
Jul 7, 2016, 10:49:58 AM7/7/16
to Haxe

A huge 'Ah!', and a huge 'Thank you'.

Now, I see clearly.
;-)

Kind regards
Arnim
Reply all
Reply to author
Forward
0 new messages