<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx</link><description>I thought I might spend a few days talking about the JScript and JScript .NET type systems, starting with some introductory material. There is a lot of terminology associated with type systems. What exactly is weak typing? What is a subtype? Just what</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Re:[HS Total]  [Objet ou pas?] - Page 2 | hilpers</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#9368867</link><pubDate>Thu, 22 Jan 2009 19:15:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9368867</guid><dc:creator>Re:[HS Total]  [Objet ou pas?] - Page 2 | hilpers</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.hilpers.fr/526142-hs-total-objet-ou-pas/2"&gt;http://www.hilpers.fr/526142-hs-total-objet-ou-pas/2&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9368867" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53349</link><pubDate>Sat, 08 Nov 2003 05:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53349</guid><dc:creator>Isaac</dc:creator><description>Can we find a better forum for this discussion?

&amp;gt;&amp;gt; They got rid of type restrictions
&amp;gt; Except they didn't. 

Wasn't it clear from the context that &amp;quot;type restrictions&amp;quot; refered to type restrictions on variables? Ain't none of those in Smalltalk ;-)

I'm a bit surprised that there's anything controversial about this - back in 1990, Justin Graver &amp;amp; Ralph Johnson were quite clear that &amp;quot;Smalltalk is untyped&amp;quot;, see &amp;quot;A Type System for Smalltalk&amp;quot;.
http://citeseer.nj.nec.com/graver90type.html

&amp;gt; Sending floogle to myVariable is a type error
It might be if Dictionary was a type, but it isn't - it's a class. Implementation is inherited, specification is ignored (notably in Dictionary being a subclass of Set - see the paper). 
So &amp;quot;Sending floogle to myVariable&amp;quot; is just messageNotUnderstood ;-)
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53349" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53348</link><pubDate>Sat, 08 Nov 2003 01:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53348</guid><dc:creator>Michael Feathers</dc:creator><description>&amp;gt;This kind of definition has been called misleading because languages &amp;gt;without typed variables do have values of different types.
&amp;gt;OTOH being *untyped* is the easy explanation for why we have ad-hoc &amp;gt;polymorphism and loose-coupling in these languages. They got rid of type &amp;gt;restrictions - proud to be untyped and safe.

Except they didn't.  

myVariable := Dictionary new.
myVariable floggle.

Sending floogle to myVariable is a type error, it is just one detected at run-time.
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53348" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53347</link><pubDate>Sat, 08 Nov 2003 01:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53347</guid><dc:creator>Isaac</dc:creator><description>&amp;gt; It sounds like he is talking about variables, and that's fine
Yes, the definition is in terms of the range of values that can be assigned to a variable. 

&amp;gt; but in some OO languages you don't have data variables,
&amp;gt; you have references to objects
The distinction between value types and reference types is unimportant to this definition. In a typed language we may restrict a variable to hold references to a particular type - such as POINTER TO ZipFile. In an untyped language we don't do that. 

&amp;gt; Now which is the variable? The object or the reference that holds it? 
&amp;gt; If you say it is the reference, then all references have the same type
I'm unsure what you mean. Let's be more concrete (Smalltalk):
   | myVariable |
   myVariable := OrderedCollection new.
Now myVariable holds a reference to an instance of OrderedCollection.
   myVariable := Dictionary new.
Now myVariable holds a reference to an instance of Dictionary.

myVariable is &amp;quot;the variable&amp;quot;. Any value can be assigned to myVariable. The language is untyped.

In some other language
   ArrayList myVariable = new ArrayList();
Now myVariable holds a reference to an instance of ArrayList.
   myVariable = new HashMap();
***Fails - the range of values that myVariable may hold is restricted to references to ArrayList instances. The language is typed.

This kind of definition has been called misleading because languages without typed variables do have values of different types.
OTOH being *untyped* is the easy explanation for why we have ad-hoc polymorphism and loose-coupling in these languages. They got rid of type restrictions - proud to be untyped and safe.

In that universe, &amp;quot;JScript Classic&amp;quot; would be untyped, and &amp;quot;JScript .NET&amp;quot; would be typed (presumably &amp;quot;untyped&amp;quot; variables are &amp;quot;restricted&amp;quot; to some universal type).



&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53347" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53346</link><pubDate>Fri, 07 Nov 2003 23:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53346</guid><dc:creator>Just some guy</dc:creator><description>Eric Lippert Writes:
&amp;quot;I'm not following your train of thought here...if every member of X is a member of Y then X is a subset of Y. &amp;quot;

Thank you for clearing me up. My confusion was in thinking that increasing the functionality in the subclass increases the values it can represent... like a TitledBorder with a Border superclass. 

I just assumed that the Border type does not include a border with a title, because  it does not properly handle the title, ( has no operators for title)  it shold not include values with titles....  only the TitledBorder type  should include that valeu.  But a TitledBorder also can handle a border with not title, as it is also a border. So I just assumed that TitledBorder will represnt a superset..

But as you note, the Border type should include borders that have titles. Even if it can not represent thoese titles properly.  It just seemed silly that a border without a title is not a valid TitledBorder  (or a zipfile without a manifes is a valid jar file).. but the reverse is ture, even though i have no way of representing/manipulating the title/manifest.

But i see my fault. :)
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53346" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53345</link><pubDate>Fri, 07 Nov 2003 11:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53345</guid><dc:creator>Curt Sampson</dc:creator><description>You seem to have confused the &amp;quot;set of possible values.&amp;quot; With type systems here we're concerned about the number of possible values a variable can hold. A variable of type ZipFile can reference any ZipFile object, and any JarFile object. But a variable of type JarFile can reference only JarFile objects, not ZipFile objects that are not JarFile objects. Thus, a JarFile variable holds a subset of the values that can be held in a ZipFile variable.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53345" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53344</link><pubDate>Fri, 07 Nov 2003 09:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53344</guid><dc:creator>Eric Lippert</dc:creator><description>&amp;gt; You describe a subtype in terms of a subset of the possible values of a super type. But in practice (in most all exaples I have seen , in textbooks and so forth) the opposite is true
&amp;gt; For example the class java.util.zip.JarFile extends java.util.zip.ZipFile, but it represents both a zip file AND a jar file, so clearly it's set of possible values is larger.

If JarFile is a subtype of ZipFile then every instance of JarFile is also an instance of ZipFile.  But that's the definition of &amp;quot;subset&amp;quot; -- if every member of X is a member of Y then X is a subset of Y.  

Therefore, I'm not following your train of thought here.  The set of all objects that are ZipFiles contains all JarFiles plus all the non-JarFile instances of ZipFiles, so how could JarFiles be a larger set?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53344" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53343</link><pubDate>Fri, 07 Nov 2003 08:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53343</guid><dc:creator>Michael Feathers</dc:creator><description>&amp;gt;It's unclear to me why we cannot work with the terms defined by Luca &amp;gt;Cardelli (in Handbook of Computer Science and Engineering, Chapter 103. &amp;gt;CRC Press, 1997; http://citeseer.nj.nec.com/cardelli97type.html
&amp;gt;typed (untyped)
&amp;gt;&amp;quot;A program variable can assume a range of values during the execution of a &amp;gt;program. An upper bound of such a range is called a type of the variable. &amp;gt;Languages that do not restrict the range of variables are called untyped &amp;gt;languages.&amp;quot;

It sounds like he is talking about variables, and that's fine, but in some OO languages you don't have data variables, you have references to objects.   Calling languages like these untyped doesn't make much sense because the objects themselves obviously have types.  In other words, the languages features are at a level of abstraction where that definition isn't very relevant.

Another example.  In some languages you don't have to be particularly concerned if you attempt to increment an integer beyond its range.  The object adjusts its range dynamically.  Now which is the variable?  The object or the reference that holds it?  If you say it is the reference, then all references have the same type, but if you say it is the object, well, what is its type really?  And, do you ever assign an object to another?  In many OO languages you can't you can only assign references.  &lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53343" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53342</link><pubDate>Fri, 07 Nov 2003 08:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53342</guid><dc:creator>Michael Feathers</dc:creator><description>&amp;gt;It's unclear to me why we cannot work with the terms defined by Luca &amp;gt;Cardelli (in Handbook of Computer Science and Engineering, Chapter 103. &amp;gt;CRC Press, 1997; http://citeseer.nj.nec.com/cardelli97type.html
&amp;gt;typed (untyped)
&amp;gt;&amp;quot;A program variable can assume a range of values during the execution of a &amp;gt;program. An upper bound of such a range is called a type of the variable. &amp;gt;Languages that do not restrict the range of variables are called untyped &amp;gt;languages.&amp;quot;

It sounds like he is talking about variables, and that's fine, but in some OO languages you don't have data variables, you have references to objects.   Calling languages like these untyped doesn't make much sense because the objects themselves obviously have types.  In other words, the languages features are at a level of abstraction where that definition isn't very relevant.

Another example.  In some languages you don't have to be particularly concerned if you attempt to increment an integer beyond its range.  The object adjusts its range dynamically.  Now which is the variable?  The object or the reference that holds it?  If you say it is the reference, then all references have the same type, but if you say it is the object, well, what is its type really?  And, do you ever assign an object to another?  In many OO languages you can't you can only assign references.  &lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53342" width="1" height="1"&gt;</description></item><item><title>RE: The JScript Type System, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/the-jscript-type-system-part-one.aspx#53341</link><pubDate>Fri, 07 Nov 2003 04:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53341</guid><dc:creator>Just some guy</dc:creator><description>You describe a subtype in terms of a subset of the possible values of a super type. But in practice (in most all exaples I have seen , in textbooks and so forth) the opposite is true... This convention is also enforced by some language rules (which I will get to).

For example the class java.util.zip.JarFile extends java.util.zip.ZipFile, but it represents both a zip file AND a jar file, so clearly it's set of possible values is larger. But it is also a subtype of ZipFile.... how can this be? does it violate the rules of subtypeing? and if it did, why does the  compiler not reject it?

Because most all languges have subtypes inheret attributes of the supertpe,  it is easy for developers to make these kinds of mistakes.     

&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=53341" width="1" height="1"&gt;</description></item></channel></rss>