<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/1.5.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Adobe Director: Type overloading using ancestors</title>
	<link>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors</link>
	<description>User Interface , Art, Design, Games</description>
	<pubDate>Wed, 08 Oct 2008 11:13:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.2</generator>

	<item>
 		<title>Comment on Adobe Director: Type overloading using ancestors by: Hanford</title>
		<link>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-117813</link>
		<pubDate>Tue, 03 Jul 2007 02:11:18 +0000</pubDate>
		<guid>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-117813</guid>
					<description>Test.</description>
		<content:encoded><![CDATA[	<p>Test.</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on Adobe Director: Type overloading using ancestors by: Phylobates</title>
		<link>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-111882</link>
		<pubDate>Thu, 21 Jun 2007 16:30:33 +0000</pubDate>
		<guid>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-111882</guid>
					<description>I'm been using director for years and you think you got it pretty much sussed when a little gem of knowledge like that pops up.. interesting. Tried with &quot;rect&quot; and it works beautifully. I'm sure I'll find some use for it...


-- New rect object in script customRect
on new me
  me.ancestor = rect(0,0,0,0)
  return me
end

on diagonalLength me
  return sqrt((me.width*me.width) + (me.height * me.height))
end

-- and lo and behold..

myrect = new script(&quot;customRect&quot;)
myrect.top = 50
myrect.right = 50
put myrect.diagonalLength()
-- 71</description>
		<content:encoded><![CDATA[	<p>I&#8217;m been using director for years and you think you got it pretty much sussed when a little gem of knowledge like that pops up.. interesting. Tried with &#8220;rect&#8221; and it works beautifully. I&#8217;m sure I&#8217;ll find some use for it&#8230;</p>
	<p>-- New rect object in script customRect<br />
on new me</p>
	<p>  me.ancestor = rect(0,0,0,0)<br />
  return me<br />
end</p>
	<p>on diagonalLength me</p>
	<p>  return sqrt((me.width*me.width) + (me.height * me.height))<br />
end</p>
	<p>-- and lo and behold..</p>
	<p>myrect = new script(&#8220;customRect&#8221;)<br />
myrect.top = 50<br />
myrect.right = 50<br />
put myrect.diagonalLength()<br />
-- 71</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on Adobe Director: Type overloading using ancestors by: ahoeben</title>
		<link>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-55999</link>
		<pubDate>Thu, 01 Feb 2007 12:25:28 +0000</pubDate>
		<guid>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-55999</guid>
					<description>The 'on put me' approach does not seem to work. Your reply got me thinking though, and the solution is as simple as:

myList = new(script(“BetterList”),[11,22,33])

put myList.ancestor
-- [11,22,33]

put myList.ancestor * 4
-- [44,88,132]

put myList.ancestor + [1,2,3]
-- [12,24,36]</description>
		<content:encoded><![CDATA[	<p>The &#8216;on put me&#8217; approach does not seem to work. Your reply got me thinking though, and the solution is as simple as:</p>
	<p>myList = new(script(&#8220;BetterList&#8221;),[11,22,33])</p>
	<p>put myList.ancestor<br />
-- [11,22,33]</p>
	<p>put myList.ancestor * 4<br />
-- [44,88,132]</p>
	<p>put myList.ancestor + [1,2,3]<br />
-- [12,24,36]</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on Adobe Director: Type overloading using ancestors by: Hanford</title>
		<link>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-55941</link>
		<pubDate>Thu, 01 Feb 2007 10:51:28 +0000</pubDate>
		<guid>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-55941</guid>
					<description>Interesting about losing those aspects of list functionality. You can, of course write your own &quot;put&quot;, like this:

on put me
trace(ancestor)
end

I like the change you made to the &quot;new&quot; handler. Valentin does something similar, but in my original example I wanted it to be as simple as possible.</description>
		<content:encoded><![CDATA[	<p>Interesting about losing those aspects of list functionality. You can, of course write your own &#8220;put&#8221;, like this:</p>
	<p>on put me<br />
trace(ancestor)<br />
end</p>
	<p>I like the change you made to the &#8220;new&#8221; handler. Valentin does something similar, but in my original example I wanted it to be as simple as possible.</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on Adobe Director: Type overloading using ancestors by: ahoeben</title>
		<link>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-55926</link>
		<pubDate>Thu, 01 Feb 2007 10:09:24 +0000</pubDate>
		<guid>http://blog.hanfordlemoore.com/2007/02/01/adobe-director-type-overloading-using-ancestors#comment-55926</guid>
					<description>If you change the 'new' handler slightly, you can set initial list values upon script initialisation:


on new me, aList
  if not listP(aList) then aList = []
  ancestor = aList
  
  return me
end

usage:
myList = new(script(&quot;BetterList&quot;),[11,22,33])
put myList[2]
-- 22

While this technique is very usefull to add 'methods' to the list datatype (such as an 'addOnce' method to only add an item to a list if it is not already in the list, or an 'append' to append another list to this list, etc), you also loose a lot of list functionality:
-  you can no longer 'put' the list 
-  you can no longer do arithmetics on the full list (eg multiply all list items by 2)
I think that's the reason why acestors aren't used more to extend datatypes...</description>
		<content:encoded><![CDATA[	<p>If you change the &#8216;new&#8217; handler slightly, you can set initial list values upon script initialisation:</p>
	<p>on new me, aList</p>
	<p>  if not listP(aList) then aList = []<br />
  ancestor = aList</p>
	<p>  return me<br />
end</p>
	<p>usage:<br />
myList = new(script(&#8220;BetterList&#8221;),[11,22,33])<br />
put myList[2]<br />
-- 22</p>
	<p>While this technique is very usefull to add &#8216;methods&#8217; to the list datatype (such as an &#8216;addOnce&#8217; method to only add an item to a list if it is not already in the list, or an &#8216;append&#8217; to append another list to this list, etc), you also loose a lot of list functionality:&#8212; you can no longer &#8216;put&#8217; the list&#8212; you can no longer do arithmetics on the full list (eg multiply all list items by 2)<br />
I think that&#8217;s the reason why acestors aren&#8217;t used more to extend datatypes&#8230;</p>
]]></content:encoded>
				</item>
</channel>
</rss>
