Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Muzak
You might find the answer here:
http://www.ecma-international.org/publications/standards/Ecma-262.htm

Furthermore, in Flash 4, a colon was used to get/set a variable in a certain 
timeline.
If I remember correcty, it looked something like this:

phrases/introduction:String = "blah";

Where 'String' would be a variable and 'introduction' a MovieClip inside 
'phrases', also a MovieClip.

regards,
Muzak

- Original Message - 
From: "Jason Lutes" <[EMAIL PROTECTED]>

> I also find it strange that you can't do this:
>
> var phrases:Object = new Object();
> phrases.introduction:String = 'Bem vindo a todos.';
>
> - or even -
>
> var phrases:Array = new Array();
> phrases[0]:String = 'Bem vindo a todos.';
>
> Should dynamically created properties/elements really be that bastardized
> in ActionScript? One of the advantages of strict data typing is the
> disambiguation of the code. I miss the ability to completely disambiguate
> in certain situations. For example, I occasionally use loops to generate
> objects or populate arrays, and would like to be able to strictly identify
> (for the sake of readability) any new properties/elements added within
> that loop.
>
> I can get around the limitation by directly passing a value to a _simple_
> datatype's constructor during assignment. This identifies the expected
> value's type for me in many situations, but other constructors don't
> accept a direct value this way.
>
> I'm not encouraging/perpetuating bad programming practices here. There's
> legitimate reason to wonder about this.
>


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread JesterXL
The source for the frustration was AS2 was implemented in a frame-script 
based landscape.  So, using class only formats for _root timelines didn't 
mesh.

You can't do private var cow:String; on _root, so when many of us went:

cow:String = "moo";

Many of us thought that was a bug.  In reality, it's shoe-horning good 
coding practices & features into a timeline.  In short, a subtle message of 
"stop coding on frames."

- Original Message - 
From: "Ian Thomas" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 12:11 PM
Subject: Re: [Flashcoders] Strict Datatyping Question


Matt,

See all the previous mails. It's not a bug, so won't have been fixed. It's
the way that the language is supposed to work.

Ian

On 10/31/05, Adams, Matt <[EMAIL PROTECTED]> wrote:
>
> Has the bug been fixed in 8?
>
>
> Matt
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread JesterXL
Apparently I've been corrected and it's not a bug.

- Original Message - 
From: "Adams, Matt" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 11:52 AM
Subject: RE: [Flashcoders] Strict Datatyping Question


Has the bug been fixed in 8?


Matt

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of JesterXL
Sent: Monday, October 31, 2005 11:01 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Strict Datatyping Question

To clarify, it changes to the type as far as the compiler is concerned,
but at runtime, yes, it's just a MovieClip.

- Original Message -
From: "Ian Thomas" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 10:44 AM
Subject: Re: [Flashcoders] Strict Datatyping Question


On 10/31/05, Ian Thomas <[EMAIL PROTECTED]> wrote:
>
>
> So in short - you can do exactly what you wrote down, but:
> - Only because MovieClip is a dynamic class


Actually, skip that - it only works later in your code if you call
methods
of MyCustomForm because it's a dynamic class. The assignment you make is
perfectly legal - but still doesn't change the type.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


---
***National City made the following annotations
---
This communication is a confidential and proprietary business communication. 
It is intended solely for the use of the designated recipient(s).  If this 
communication is received in error, please contact the sender and delete 
this communication.
===
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Ian Thomas
Matt,

See all the previous mails. It's not a bug, so won't have been fixed. It's
the way that the language is supposed to work.

Ian

On 10/31/05, Adams, Matt <[EMAIL PROTECTED]> wrote:
>
> Has the bug been fixed in 8?
>
>
> Matt
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Adams, Matt
Has the bug been fixed in 8? 


Matt 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of JesterXL
Sent: Monday, October 31, 2005 11:01 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Strict Datatyping Question

To clarify, it changes to the type as far as the compiler is concerned,
but at runtime, yes, it's just a MovieClip.

- Original Message -
From: "Ian Thomas" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 10:44 AM
Subject: Re: [Flashcoders] Strict Datatyping Question


On 10/31/05, Ian Thomas <[EMAIL PROTECTED]> wrote:
>
>
> So in short - you can do exactly what you wrote down, but:
> - Only because MovieClip is a dynamic class


Actually, skip that - it only works later in your code if you call
methods
of MyCustomForm because it's a dynamic class. The assignment you make is
perfectly legal - but still doesn't change the type.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


---
***National City made the following annotations
---
This communication is a confidential and proprietary business communication.  
It is intended solely for the use of the designated recipient(s).  If this 
communication is received in error, please contact the sender and delete this 
communication.
===
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Ian Thomas
No - it _doesn't_ change the type of the variable from the compiler's PoV,
that's my point. :-)

I've probably been explaining really badly.

The statement:

var my_var:A;

defines a thing which can point to objects of type A.

This thing can only _ever_ hold references to objects of type A and objects
derived from A; never anything else.

So, assuming class C extends class B which extends class A:

var b1:B = new A(); // Compiler chokes, as it can't guarantee that all the
methods B defines
are available in A. Compilation would stop here.
var b2:B = new B(); // no problem
var b3:B = new C(); // again, no problem, because C inherits from B and the
compiler is
happy that C can do everything B can.

b2.doAMethodDefinedInA(); // Fine - compiler knows that B extends A
b2.doAMethodDefinedInB(); // Again, fine.

b3.doAMethodDefinedInA(); // Still fine
b3.doAMethodDefinedInB(); // Yup.
b3.doAMethodDefinedInC(); // Nope. The compiler thinks that b3 is of object
type B - it knows nothing of C, because 'b3' was defined as being of type B
in it's declaration.

Note that the last line would compile fine if class B were defined as
'dynamic' - because it's dynamic, the compiler throws out all type-checking
on B. There go the safety-nets... which is what was happening in your
MovieClip example.

Now, if the _programmer_ was happy that b3 was _actually_ a C, he could
always type:

var c:C=C(b3); // Downcasting is perfectly legal...
c.doAMethodDefinedInC(); // And now the compiler is happy

I hope that's clearer. :-D But now I'm probably waaay off the original
topic, whatever it was... sorry, it's been a helluva weekend. ;-)

Ian


On 10/31/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> To clarify, it changes to the type as far as the compiler is concerned,
> but
> at runtime, yes, it's just a MovieClip.
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Jason Lutes
> Why it is illegal to combine both a path declaration and a datatype
> declaration  in the same expression" i.e.:

I also find it strange that you can't do this:

var phrases:Object = new Object();
phrases.introduction:String = 'Bem vindo a todos.';

- or even -

var phrases:Array = new Array();
phrases[0]:String = 'Bem vindo a todos.';

Should dynamically created properties/elements really be that bastardized
in ActionScript? One of the advantages of strict data typing is the
disambiguation of the code. I miss the ability to completely disambiguate
in certain situations. For example, I occasionally use loops to generate
objects or populate arrays, and would like to be able to strictly identify
(for the sake of readability) any new properties/elements added within
that loop.

I can get around the limitation by directly passing a value to a _simple_
datatype's constructor during assignment. This identifies the expected
value's type for me in many situations, but other constructors don't
accept a direct value this way.

I'm not encouraging/perpetuating bad programming practices here. There's
legitimate reason to wonder about this.


-
pixelTwiddler, a.k.a. Jason


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread JesterXL
To clarify, it changes to the type as far as the compiler is concerned, but 
at runtime, yes, it's just a MovieClip.

- Original Message - 
From: "Ian Thomas" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 10:44 AM
Subject: Re: [Flashcoders] Strict Datatyping Question


On 10/31/05, Ian Thomas <[EMAIL PROTECTED]> wrote:
>
>
> So in short - you can do exactly what you wrote down, but:
> - Only because MovieClip is a dynamic class


Actually, skip that - it only works later in your code if you call methods
of MyCustomForm because it's a dynamic class. The assignment you make is
perfectly legal - but still doesn't change the type.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread JesterXL
You don't ever actually change anything in AS2 though; you can't.  My 
example is just showing you are telling the compiler that you are changing 
it's type; I know full well it's type never changes.  You can use Number, 
int, String, parseInt, and parseFloat; but only 2 of those can be used as 
datatyping, but no coercion.

- Original Message - 
From: "Ian Thomas" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 10:42 AM
Subject: Re: [Flashcoders] Strict Datatyping Question


Nope.

my_win, the variable, is still declared (to the compiler) as a MovieClip. It
only knows about it as type MovieClip.

The object it 'points to' happens to be of type MyCustomForm, which is an
object that inherits from MovieClip. It does all the things that MovieClip
does, just does more stuff too.

>From a compiler perspective, you can get away with calling methods of
MyCustomForm on your my_win _only because_ MovieClip is a dynamic class, and
so the compiler throws away all type-checking for my_win. It does mean that
anything you call on my_win will not be properly type checked.

If you had used a non-dyamic class in your example, the problem would have
become a lot more obvious. For example:

class A
{
public function doSomething() {trace("Do Something");}
}

class B extends A
{
public function doSomethingElse() {trace("Do Something Else");}
}

var my_a:A;

my_a=B(createBSomeHow()); // The compiler will choke on this line

my_a.doSomething(); // Compiler will be fine with this
my_a.doSomethingElse(); // Compiler would choke on this

or if it was:
var my_a:A;
my_a = A(createBSomeHow()); // Perfectly legal 'cos B inherits from A

my_a.doSomething(); // No problems
my_a.doSomethingElse(); // Compiler chokes, because it only knows that 'a'
is an A.


So in short - you can do exactly what you wrote down, but:
- Only because MovieClip is a dynamic class
- You're skipping compiler type-checking because MovieClip is a dynamic
class (so any type-signatures of methods of MyCustomForm you call will be
unchecked - which might be an issue if you, for example, went back and
redefined them later)
- You aren't actually changing the type of my_win. It's still a MovieClip,
as far as the compiler can see.

Cheers,
Ian

On 10/31/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> >>>You can't change the type of a variable during an assignment
>
> Yes you can.
>
> var my_win:MovieClip;
>
> my_win = MyCustomForm(PopUpManager.createPopUp(this, MyCustomForm,
> false));
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Ian Thomas
On 10/31/05, Ian Thomas <[EMAIL PROTECTED]> wrote:
>
>
> So in short - you can do exactly what you wrote down, but:
> - Only because MovieClip is a dynamic class


Actually, skip that - it only works later in your code if you call methods
of MyCustomForm because it's a dynamic class. The assignment you make is
perfectly legal - but still doesn't change the type.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Ian Thomas
Nope.

my_win, the variable, is still declared (to the compiler) as a MovieClip. It
only knows about it as type MovieClip.

The object it 'points to' happens to be of type MyCustomForm, which is an
object that inherits from MovieClip. It does all the things that MovieClip
does, just does more stuff too.

>From a compiler perspective, you can get away with calling methods of
MyCustomForm on your my_win _only because_ MovieClip is a dynamic class, and
so the compiler throws away all type-checking for my_win. It does mean that
anything you call on my_win will not be properly type checked.

If you had used a non-dyamic class in your example, the problem would have
become a lot more obvious. For example:

class A
{
public function doSomething() {trace("Do Something");}
}

class B extends A
{
public function doSomethingElse() {trace("Do Something Else");}
}

var my_a:A;

my_a=B(createBSomeHow()); // The compiler will choke on this line

my_a.doSomething(); // Compiler will be fine with this
my_a.doSomethingElse(); // Compiler would choke on this

or if it was:
var my_a:A;
my_a = A(createBSomeHow()); // Perfectly legal 'cos B inherits from A

my_a.doSomething(); // No problems
my_a.doSomethingElse(); // Compiler chokes, because it only knows that 'a'
is an A.


So in short - you can do exactly what you wrote down, but:
- Only because MovieClip is a dynamic class
- You're skipping compiler type-checking because MovieClip is a dynamic
class (so any type-signatures of methods of MyCustomForm you call will be
unchecked - which might be an issue if you, for example, went back and
redefined them later)
- You aren't actually changing the type of my_win. It's still a MovieClip,
as far as the compiler can see.

Cheers,
Ian

On 10/31/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> >>>You can't change the type of a variable during an assignment
>
> Yes you can.
>
> var my_win:MovieClip;
>
> my_win = MyCustomForm(PopUpManager.createPopUp(this, MyCustomForm,
> false));
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread JesterXL
>>>You can't change the type of a variable during an assignment

Yes you can.

var my_win:MovieClip;

my_win = MyCustomForm(PopUpManager.createPopUp(this, MyCustomForm, false));

- Original Message - 
From: "Ian Thomas" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 4:28 AM
Subject: Re: [Flashcoders] Strict Datatyping Question


Jester, that's not a bug. The two statements ' var ' and
'=' are totally different things.

'var ' is a declaration. Which you can tack a handy assignment on
to the end of ( = something), because it's always good to initialise your
variables when you declare them. But the main purpose of the statement is to
declare the variable.

'myVar = ' is different - it's an assignment of a new value to a
variable which has already been declared. You can't change the type of a
variable during an assignment, so putting ':' after the variable
name is meaningless.

HTH,
Ian

On 10/31/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> Finally, there is a bug in Flash MX 2004 & 8; you can't datatype like
> this:
>
> myVar:Number = 42;
>
> but you can do this:
>
> var myVar:Number = 42;
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Robert Tweed

Chris Velevitch wrote:

I think the confusion occurs because you seem to be mixing up the
distinction between declaration and reference.


Another distinction, which isn't very clear in ActionScript, is the 
distinction between declaration and definition. The declaration is where 
you tell the compiler what is supposed to exist. The definition is where 
you create the things that actually exist. The definition needs to match 
the declaration.


In ActionScript these generally happen at the same time, e.g.:

   var x : Number;

That means:

   1. Declare that a variable called "x" exists and has the type "Number"
   2. Define a variable called "x" and allocate the memory for it. Make 
it a Number.


In ActionScript, you can't have a declaration without a definition. 
However, you can have a definition without a declaration. E.g.:


   this.x = 10;

That's a definition. "x" is a variable of type Number containing the 
number 10.


If you happen to have a declaration elsewhere that says, for instance, 
that x should be a String, then this will cause a compiler error because 
the definition doesn't match the declaration. However, if there is no 
declaration and you are not working with a non-dynamic class, 
ActionScript just allows this to go as a "dynamic" variable: one whose 
type is not known at compile time because it is defined at runtime 
without a formal declaration.


Variables are always declared with "var" because that ensures they are 
being created in the local scope. You can't go declaring things in a 
different scope, because aside from anything else, that would break the 
OOP black-box model. It would be like me coming into your house and 
rearranging your furniture while you were out. It doesn't work like 
that, because the compiler needs to rely on a single, authoritative 
declaration.


- Robert
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-31 Thread Ian Thomas
Jester, that's not a bug. The two statements ' var ' and
'=' are totally different things.

'var ' is a declaration. Which you can tack a handy assignment on
to the end of ( = something), because it's always good to initialise your
variables when you declare them. But the main purpose of the statement is to
declare the variable.

'myVar = ' is different - it's an assignment of a new value to a
variable which has already been declared. You can't change the type of a
variable during an assignment, so putting ':' after the variable
name is meaningless.

HTH,
Ian

On 10/31/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> Finally, there is a bug in Flash MX 2004 & 8; you can't datatype like
> this:
>
> myVar:Number = 42;
>
> but you can do this:
>
> var myVar:Number = 42;
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-30 Thread Liam Morley
Jester, that's actually in the documentation, that's not a bug. I don't
remember where I read it, but I found it somewhere when I was looking into
scope. You can search around in here:
http://livedocs.macromedia.com/flash/8/main/1200.html if you're
interested.

As to your original question, the answer depends on whether or not "myVar"
is already defined in clip1. If it is, then as others have said, you can't
declare something twice. You didn't mention in your question as to whether
or not you're trying to declare it in two places. It's my opinion that
declaring a variable in a different scope using strong typing is illegal
because AS enforces you to be consistent with the "spirit of the code". I'll
explain.

The following is an illegal declaration:

// llegal syntax error: Identifier expected
this.clip1.myVar:Number;

This is pretty similar to your statement, except that I cut out the
assignment, as it only clouds the issue. Before ActionScript introduced
strong typing, you could define variables in any scope at any time. While
this offers a greater range of possibilities, it also introduces a lot more
danger, and as such is appropriate for small-time scripting, not larger
software projects. Strong typing is useful because it helps keep you out of
danger- it makes sure that variables can not change type implicitly. It's
usually not appropriate for small scripting projects, as you're usually
dealing with tasks small enough that you never run into type-related issues.

AS2 supports the programmer working on a large project by offering strong
typing, and the scripter/designer who isn't doing much with AS by offering
dynamic variable declaration. AS2 however (at least in this case) does not
really support both at the same time. It makes sense that, if you're using
strong typing, you're working on a project where you don't want to support
shortcuts like dynamic declaration. If you want strong typing, then you
shouldn't be declaring myVar outside the scope of clip1; if you want dynamic
declaration, then why are you wasting time with strong typing?

I hope that made sense.
Liam


On 10/31/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> Finally, there is a bug in Flash MX 2004 & 8; you can't datatype like
> this:
>
> myVar:Number = 42;
>
> but you can do this:
>
> var myVar:Number = 42;
>
> - Original Message -
> From: "Chris Velevitch" <[EMAIL PROTECTED]>
> To: "Flashcoders mailing list" 
> Sent: Monday, October 31, 2005 12:30 AM
> Subject: Re: [Flashcoders] Strict Datatyping Question
>
>
> On 10/31/05, Joseph Balderson <[EMAIL PROTECTED]> wrote:
> > Why it is illegal to combine both a path declaration and a datatype
> > declaration
> > in the same expression" i.e.:
> ...
> > // illegal syntax error
> > this.clip1.myVar:Number = 42;
>
> This illegal because myVar has already be declared in the definition
> of the type of clip1.
>
> Also, you have used the phase 'path declaration'. This is an oxymoron.
> Declarations only appear in a class definition, paths are references
> to the objects/types of interest.
>
>
> Chris
> --
> Chris Velevitch
> Manager - Sydney Flash Platform Developers Group
> www.flashdev.org.au <http://www.flashdev.org.au>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-30 Thread Chris Velevitch
On 10/31/05, Joseph Balderson <[EMAIL PROTECTED]> wrote:
> So what you're saying is, when I declare a variable using a path reference, 
> I'm
> really creating a dynamic variable. Because the type of a dynamic variable is
> only determined at runtime when the variable is given a value, and type 
> checking
> is done at compile-time, you can't typecast an object as Number when it's
> already been typecast as dynamic at compile-time? Or is it the reverse? Still 
> a
> little confused...

I think the confusion occurs because you seem to be mixing up the
distinction between declaration and reference.

You declare variables like

  var x:Y;

you refer to variables like

  a = z.x;

or

 if (z.x == 42) ...


Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
www.flashdev.org.au
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-30 Thread Joseph Balderson

Robert Tweed wrote:
When you specify a type, you are declaring an object to the compiler. 
Based on that, the compiler will check the code for any expressions that 
conflict with the known declaration. It can only do this at 
compile-time: there is no runtime type-checking.


When you use a path reference, you are doing one of three things:

1. Dereferencing a typed variable, which must be declared somewhere else.
2. Dereferencing an existing dynamic variable.
3. Creating a dynamic variable at runtime.

The reasons why none of these can legally have a type specifier:

1. You can't declare something twice - the compiler already knows the type.
2. By definition, you can't know what type it is, so trying to specify 
one here is a form of unsafe casting.


So what you're saying is, when I declare a variable using a path reference, I'm 
really creating a dynamic variable. Because the type of a dynamic variable is 
only determined at runtime when the variable is given a value, and type checking 
is done at compile-time, you can't typecast an object as Number when it's 
already been typecast as dynamic at compile-time? Or is it the reverse? Still a 
little confused...



3. In this case any declaration to the compiler is meaningless.

- Robert
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-30 Thread JesterXL
Finally, there is a bug in Flash MX 2004 & 8; you can't datatype like this:

myVar:Number = 42;

but you can do this:

var myVar:Number = 42;

- Original Message - 
From: "Chris Velevitch" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Monday, October 31, 2005 12:30 AM
Subject: Re: [Flashcoders] Strict Datatyping Question


On 10/31/05, Joseph Balderson <[EMAIL PROTECTED]> wrote:
> Why it is illegal to combine both a path declaration and a datatype 
> declaration
> in the same expression" i.e.:
...
> // illegal syntax error
> this.clip1.myVar:Number = 42;

This illegal because myVar has already be declared in the definition
of the type of clip1.

Also, you have used the phase 'path declaration'. This is an oxymoron.
Declarations only appear in a class definition, paths are references
to the objects/types of interest.


Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
www.flashdev.org.au
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-30 Thread Robert Tweed

Joseph Balderson wrote:
Why it is illegal to combine both a path declaration and a datatype 
declaration in the same expression" i.e.:

[snip]

// illegal syntax error
this.clip1.myVar:Number = 42;


When you specify a type, you are declaring an object to the compiler. 
Based on that, the compiler will check the code for any expressions that 
conflict with the known declaration. It can only do this at 
compile-time: there is no runtime type-checking.


When you use a path reference, you are doing one of three things:

1. Dereferencing a typed variable, which must be declared somewhere else.
2. Dereferencing an existing dynamic variable.
3. Creating a dynamic variable at runtime.

The reasons why none of these can legally have a type specifier:

1. You can't declare something twice - the compiler already knows the type.
2. By definition, you can't know what type it is, so trying to specify 
one here is a form of unsafe casting.

3. In this case any declaration to the compiler is meaningless.

- Robert
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Strict Datatyping Question

2005-10-30 Thread Chris Velevitch
On 10/31/05, Joseph Balderson <[EMAIL PROTECTED]> wrote:
> Why it is illegal to combine both a path declaration and a datatype 
> declaration
> in the same expression" i.e.:
...
> // illegal syntax error
> this.clip1.myVar:Number = 42;

This illegal because myVar has already be declared in the definition
of the type of clip1.

Also, you have used the phase 'path declaration'. This is an oxymoron.
Declarations only appear in a class definition, paths are references
to the objects/types of interest.


Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
www.flashdev.org.au
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Strict Datatyping Question

2005-10-30 Thread Liu, Kai M
Would it be that in AS2.0, variables are required to declare locally
(within Classes to avoid namespace conflict)? Imagine if I can create
dynamic variables in your class without your permission, that could be
risky.

?? Make sense?  :-)


[...]   Sam Liu
Flash Developer - Languages Online
Office of Learning and Teaching
Department of Education and Training
 

T:  (03) 9637 2102F:  (03) 9637 2060

 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Joseph
Balderson
Sent: Monday, 31 October 2005 3:24 PM
To: Flashcoders mailing list
Subject: [Flashcoders] Strict Datatyping Question


So I'm teaching Actionscript 2.0 to second year college students, and
I've had 
to explain something very simple about datatyping. I've looked all
through 
Moock's Essential Actionscript 2.0, all the help files, all of the Flash
MX 04 
books I have plus a few in friends' and colleague's libraries, and I've
yet to 
find a satisfactory answer to this seemingly simple question:

Why it is illegal to combine both a path declaration and a datatype
declaration 
in the same expression" i.e.:

// legal - path declaration
this.clip1.myVar = 42;

// legal - datatype declaration
var myVar:Number = 42;

// illegal syntax error
this.clip1.myVar:Number = 42;


Does any one know the answer to this, it is really bugging me...



Joseph Balderson
Interactive Media Design & Development
http://www.joeflash.ca

Faculty Member, Flash Development,
Humber College School of Media Studies http://mediastudies.humber.ca

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Important - 
This email and any attachments may be confidential. If received in error, 
please contact us and delete all copies. Before opening or using attachments 
check them for viruses and defects. Regardless of any loss, damage or 
consequence, whether caused by the negligence of the sender or not, resulting 
directly or indirectly from the use of any attached files our liability is 
limited to resupplying any affected attachments. Any representations or 
opinions expressed are those of the individual sender, and not necessarily 
those of the Department of Education & Training.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders