<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PSYMusings</title>
	<atom:link href="http://remydemarest.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://remydemarest.wordpress.com</link>
	<description>A Blog about my stuff, with stuff in it.</description>
	<lastBuildDate>Mon, 25 Jan 2010 01:52:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='remydemarest.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>PSYMusings</title>
		<link>http://remydemarest.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://remydemarest.wordpress.com/osd.xml" title="PSYMusings" />
	<atom:link rel='hub' href='http://remydemarest.wordpress.com/?pushpress=hub'/>
		<item>
		<title>BambooTalk Comments</title>
		<link>http://remydemarest.wordpress.com/2010/01/25/bambootalk-comments/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/25/bambootalk-comments/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 01:52:05 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=76</guid>
		<description><![CDATA[Okay, it seems I&#8217;ve changed my mind on comments in BambooTalk. The previous syntaxes, that is &#8220;::&#8221; for one-line comments (BCPL comments, equivalent to &#8220;//&#8221; in C99/C++/ObjC), and &#8220;:# block #:&#8221; for comment blocks like the &#8220;/* block */&#8221; were not satisfying on the lexer point of view&#8230; Indeed, it required the lexer to disambiguate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=76&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Okay, it seems I&#8217;ve changed my mind on comments in BambooTalk. The previous syntaxes, that is &#8220;<code>::</code>&#8221; for one-line comments (BCPL comments, equivalent to &#8220;<code>//</code>&#8221; in C99/C++/ObjC), and &#8220;<code>:# block #:</code>&#8221; for comment blocks like the &#8220;<code>/* block */</code>&#8221; were not satisfying on the lexer point of view&#8230;</p>
<p>Indeed, it required the lexer to disambiguate expressions like that: &#8220;<code>obj setX::# comment #:value</code>&#8221; by parsing &#8220;<code>setX:</code>&#8221; as one token followed by a comment, followed by an identifier&#8230; Which would force the user to separate manually the tokens by adding spaces: &#8220;<code>obj setX ::#comment #:value</code>&#8221; would become identifier &#8220;<code>obj</code>&#8221; followed by identifier &#8220;<code>setX</code>&#8221; followed by a one-line comment.</p>
<p>So I changed that, now comment blocks would be written like that: &#8220;<code>#: comment :#</code>&#8221; and one-line comments would start with &#8220;<code>##</code>&#8220;. This syntax retains comment nesting in comment blocks and removes all ambiguities since &#8220;<code>#</code>&#8221; is merely used for nothing much currently, whereas colons are used for keyword messages, class inheritance and assign operators&#8230;</p>
<p>I&#8217;ve edited my previous posts to fit in the new syntax.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=76&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/25/bambootalk-comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>Cocoa: Blocks vs. Foreach</title>
		<link>http://remydemarest.wordpress.com/2010/01/19/cocoa-blocks-vs-foreach/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/19/cocoa-blocks-vs-foreach/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 20:56:45 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=55</guid>
		<description><![CDATA[How block iterations can be more efficient than foreach iterations in Cocoa.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=55&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is an article about the value of benchmarking !</p>
<p>When Apple announced blocks for C/ObjC/C++ in Snow Leopard, I was thrilled, what a great powerful idea for the code. On the users point of view, you could write code that can be injected into the implementor&#8217;s (Apple) algorithm, without the need to rewrite it or provide an ugly context pointer that the implementor would need to manage as well. Blocks are also great for the implementor because it allows him, without changing its API, to increase the efficiency of his algorithm over time.</p>
<p>Knowing that, I told myself: &#8220;Great! Blocks are beautiful and they can make it more efficient over time than their foreach construction&#8221;&#8230; Well, when I did benchmarks on Snow Leopard to compare -[NSArray enumerateObjectsUsingBlock:] and for( in ) construction, I was kinda disappointed&#8230; Foreach was still more efficient than the block enumeration&#8230; And by far.</p>
<p>However that&#8217;s normal, the difference between both constructions is that the -enumerateObjectsUsingBlock: needs to make a function call (the block&#8217;s code) with each parameters while iterating; whereas for( in ) does one method call for a bunch of objects (usually 16) and then do an inline iteration through the local C-array of objects.</p>
<p>Now, is foreach always more efficient than blocks in iterations ? Well no, it really depends on what you do in the iteration code. For example, it is more efficient to get the set of indexes to take from an array A to put in array B, than adding each objects one by one. That&#8217;s normal too! When you add objects one by one, the array will allocate a little block of memory to make the objects fit in it, but when you add  a whole big array, it is capable to allocate enough memory for all objects to fit in it at once&#8230;</p>
<p>In this case, the only way to make foreach to really compete with -indexesOfObjectsPassingTest: is to build the index set yourself&#8230; It would be generally slightly slower than block enumeration, because you would simply do [indexSet addIndex: idx] whereas Apple algorithm does it by ranges. So, instead of rebuilding the wheel, it is better to use the index enumeration through blocks.</p>
<p>This shows how benchmarking can be useful, when you have the choice between two seemingly efficient techniques, don&#8217;t try to guess !</p>
<p>Here follows my own benchmark for 10 million objects (on a MacBook Pro 2.8 GHz and 4 GB of RAM), here are the results I get (in seconds):</p>
<ul>
<li>Block: 2.122398</li>
<li>Foreach: 2.855717</li>
<li>Foreach indexSet: 2.224305</li>
</ul>
<p>Here is the code to do the benchmark (need to be compiled with blocks on, Foundation framework and optimization to 0):</p>
<pre><code>
#import &lt;Foundation/Foundation.h&gt;

#define COUNT 10000000

void testBlocks(NSArray *allObjects)
{
  NSMutableArray *selectedObjects =
    [NSMutableArray array];

  NSDate *start = [NSDate date];

  NSIndexSet *indexes =
    [allObjects indexesOfObjectsPassingTest:
     ^BOOL(id obj, NSUInteger idx, BOOL *stop)
     { return (idx % 20) != 0; }];

  [selectedObjects addObjectsFromArray:
   [allObjects objectsAtIndexes:indexes]];

  NSLog(@"Block: %f", -[start timeIntervalSinceNow]);
}

void testForeach(NSArray *allObjects)
{
  NSMutableArray *selectedObjects =
    [NSMutableArray array];

  NSDate *start = [NSDate date];

  NSUInteger i = 0;
  for(id obj in allObjects) if((i++ % 20) != 0)
    [selectedObjects addObject:obj];

  NSLog(@"Foreach: %f", -[start timeIntervalSinceNow]);
}

void testForeachIndex(NSArray *allObjects)
{
  NSMutableArray *selectedObjects =
    [NSMutableArray array];

  NSDate *start = [NSDate date];
  NSUInteger i = 0;
  NSMutableIndexSet *indexSet =
    [NSMutableIndexSet indexSet];

  for(id obj in allObjects)
  {
    if((i % 20) != 0) [indexSet addIndex:i];
    i++;
  }

  [selectedObjects addObjectsFromArray:
   [allObjects objectsAtIndexes:indexSet]];

  NSLog(@"Foreach indexSet: %f",
        -[start timeIntervalSinceNow]);
}

int main(int argc, char **argv)
{
  NSAutoreleasePool *pool = [NSAutoreleasePool new];

  NSMutableArray *allObjects =
    [NSMutableArray arrayWithCapacity:COUNT];

  for(NSUInteger i = 0; i &lt; COUNT; i++)
    [allObjects addObject:
     [NSNumber numberWithUnsignedInteger:i]];

  testBlocks(allObjects);

  testForeach(allObjects);

  testForeachIndex(allObjects);

  [pool drain];

  return 0;
}
</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=55&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/19/cocoa-blocks-vs-foreach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk Typing, Part V</title>
		<link>http://remydemarest.wordpress.com/2010/01/17/bambootalk-typing-part-v/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/17/bambootalk-typing-part-v/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 17:21:50 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>
		<category><![CDATA[Typing]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=53</guid>
		<description><![CDATA[Exposing features about typing: namespaces, typedefs, nesting, import and how you declare local variables.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=53&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to this new article. In this one, I will talk about the few other things concerning typing, that is namespaces, typedefs, nesting, import and how you declare local variables.</p>
<h2>The $ sign</h2>
<p>Okay, it will seem weird (or ugly) for some of you, but this is the only way I found to keep the syntax coherent and remove ambiguities in the language. The $ sign serves only one purpose in the language: defining local variables. It actually separates the type from the variable name, example: &#8220;<code>Point $ origin := value.</code>&#8220;. Spaces around it are optional. Since the $ sign is only used when declaring a variable, you can also remove the type before the $ if the type of the variable can be inferred from its initialization value. It also allows you to define multiple variable of the same type (if it is explicit). For example:</p>
<p><code><br />
Point $ origin := Point new. ## explicit type<br />
$ center := origin. ## inferred type from the origin's type<br />
$ other := Point new. ## inferred type from @Point new return type.<br />
## note you shouldn't put a period after Rect new in this declaration, because then "bounds" type would be unknown.<br />
Rect $ rect $ frame := Rect new $ bounds.<br />
</code></p>
<p>This syntax is necessary to avoid ambiguity of such declaration: &#8220;<code>AppKit BezierPath bezierPath.</code>&#8220;, is this the message &#8220;bezierPath&#8221; sent to &#8220;AppKit BezierPath&#8221; object -or- is it a declaration of the &#8220;bezierPath&#8221; variable of type &#8220;AppKit BezierPath&#8221;? The $ sign removes this ambiguity:</p>
<ul>
<li>&#8220;<code>AppKit BezierPath bezierPath.</code>&#8220;: this is the message sending;</li>
<li>&#8220;<code>AppKit BezierPath $ bezierPath.</code>&#8220;: this is the variable declaration.</li>
</ul>
<h2>Namespaces</h2>
<p>One of the big demands concerning Objective-C, was namespaces, and it seemed like a good thing to add to this language. Namespaces are just a way to group classes, types, structures, and even other namespaces. This is the syntax:</p>
<p><code>namespace NamespaceName<br />
{<br />
## declarations<br />
}</code></p>
<p>To access objects defined in the namespace, you simply use the message syntax:<br />
<code><br />
## Definition of the Cocoa namespace with a nested AppKit namespace<br />
namespace Cocoa<br />
{<br />
namespace AppKit<br />
{<br />
class BezierPath : Object { #: defs :# }<br />
}<br />
}<br />
## Using the BezierPath class outside of the Cocoa namespace<br />
Cocoa AppKit BezierPath $ path := Cocoa AppKit BezierPath new.<br />
</code></p>
<p>With that feature, you can see the use of the $ sign to indicate a variable declaration. Everywhere you can put a type you can use the whole declaration. For example: &#8220;<code>- (Cocoa AppKit BezierPath)buildPath.</code>&#8220;. The namespace construction will reduce most name collisions in bigger projects, it also allows more modularity by separating the classes into larger logical sets.</p>
<h2>Import</h2>
<p>Okay, this namespace syntax is cool, but can become really heavy when you use the same type quite often. So, you can simply use the import keyword to tell what namespace you want available  in the current scope. How do you use it: &#8220;<code>import Cocoa AppKit.</code>&#8220;. As I just said, it is scoped, so you can put it in a block and the import will only be valid for that block.</p>
<h2>Typedef</h2>
<p>Typedef allows type aliasing. Its main purpose is essentially providing a more readable name for product and sum types, but it can be used for other types as well. The syntax is as follow<code>: "typedef &lt;new_name&gt; &lt;existing_type&gt;.</code>&#8220;, example: &#8220;<code>typedef Person { String firstName, lastName. }.</code>&#8220;.</p>
<h2>Nesting</h2>
<p>We saw earlier that namespaces could be nested into other namespaces. You can do this for other types as well. Classes and structures can be nested into other classes or structures, as if you accessed it from outside of a namespace, in a similar way to C++&#8217;s &#8220;vector&lt;string&gt;::iterator&#8221;, that is the enclosing class retains its generics and can pass them to its nested classes.</p>
<p>Also, a nested class methods have the same accesses to ivars of the enclosing class&#8217;s then one of its methods. You can as well restrict access to the nested classes from outside using private or protected access modifiers. Enums can also be nested into classes or structures and have the same access restrictions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=53&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/17/bambootalk-typing-part-v/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk Typing, Part IV</title>
		<link>http://remydemarest.wordpress.com/2010/01/16/bambootalk-typing-part-iv/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/16/bambootalk-typing-part-iv/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 19:47:23 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>
		<category><![CDATA[Typing]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=47</guid>
		<description><![CDATA[In this part I talk about protocols and generics in BambooTalk.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=47&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this article, I will talk about protocols and generics. The goal of these features is more to enforce type-checking and prevent bugs related to it at compile-time.</p>
<h2>Protocols</h2>
<p>Protocols, as called in ObjC, AKA interface in Java/C#, is another tool to enforce typing. Protocols define a contract a conforming object must comply with, for objects, that require the protocol, to show exactly what they need to do their work. A protocol only declares methods and properties, a class that conforms to the protocol must implement the required methods of the protocol and can define any of the optional methods it declares. The protocol syntax is pretty simple:<br />
<code><br />
[attributes]<br />
protocol MyProtocolName &lt;Protocol, List&gt;<br />
{<br />
- (void)requiredMethod.<br />
optional<br />
- (void)optionalMethod<br />
{<br />
self requireMethod.<br />
}<br />
required<br />
- (void)otherRequiredMethod.<br />
}<br />
</code></p>
<p>Note that a protocol name is in its own namespace, which means it can have the same name as a class without collisions. As you can see, you can provide a default implementation for an optional method, it can only call required methods, or test for optional methods before calling them (unless they&#8217;re also implemented). If a class doesn&#8217;t implement an optional method, the protocol&#8217;s implementation becomes part of the class. It allows the implementor of the protocol to provide default behaviors depending on other methods of the protocol. For now, the only available attribute for protocols is &#8220;deprecated&#8221;.</p>
<h2>Generics</h2>
<p>Generics is another way to enforce typing, it&#8217;s usually used in collections. The principle is as follow: you provide at the beginning of your class, protocol or structure definition, a list of abstract type that are used throughout the construction. When the user will want to use a class that provides generics, he will be able to tell which are those actual types. For example, an array collection would define a collection of any kind of objects, and thus accept any kind of objects in or out. The user would have the possibility to tell which type he wants in that array, telling the compiler &#8220;this object will always contain string&#8221;, in this case the compiler will be able to do type-checks like &#8220;here you&#8217;re inserting an object that is not a string&#8221;.</p>
<p>The generics syntax is as follow:<br />
<code><br />
class MutableDictionary[TKey as id&lt;Copying&gt;, TValue as id] : Object<br />
{<br />
- (TValue)objectForKey:(TKey)aKey.<br />
- (Integer)count.<br />
- (void)setObject:(TValue)aValue forKey:(TKey)aKey.<br />
- (void)removeObjectForKey:(TKey)aKey.<br />
- (Array[TKey])allKeysForObject:(TValue)anObject.<br />
- (Array[TValue])objectsForKeys:(Array[TKey])aKey notFoundMarker:(TValue)marker.<br />
}<br />
</code><br />
You can see here you can define as many generic types a you want. You can then use the identifiers as types anywhere a type is expected in your class, notably as types for other generic classes. A user can also ignore the generic type of a class, by default, the type for a generic is &#8220;id&#8221;, that is &#8220;any object&#8221;. In this definition, you notice you can also force the generic type to have certain requirements.</p>
<p>As an example, in the MutableDictionary collection, the type TValue has no requirement (&#8220;as id&#8221; is optional), whereas TKey requires to conform to Copying protocol. If the user doesn&#8217;t set any type when instantiating the collection, these will be the defaults, so the compiler will do a type-check for keys to check whether the inserted object conforms to Copying protocol.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=47&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/16/bambootalk-typing-part-iv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk Typing, Part III</title>
		<link>http://remydemarest.wordpress.com/2010/01/15/bambootalk-typing-part-iii/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/15/bambootalk-typing-part-iii/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 19:40:17 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>
		<category><![CDATA[Typing]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=39</guid>
		<description><![CDATA[In this article, I talk about method, property and constructor implementations.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=39&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to this new article. This time I&#8217;m going to go deeper in complex types syntax, most of the syntax is shared between both structures and classes except things concerning inheritance.</p>
<h2>Method syntax</h2>
<p>The method syntax is basically the same as in ObjC:<br />
<code>## Class methods start with a + and Instance methods start with a -<br />
## Unary method<br />
[method, attributes]<br />
- (ReturnType)methodName<br />
{<br />
## method implementation<br />
return value.<br />
}<br />
## Binary method, binary_op is any combination of the following characters: "~ ! @ % &amp; * - + = | \  &lt; &gt; , ? / ^ `"<br />
[method, attributes]<br />
- (ReturnType) binary_op (ArgType)arg [argument, attributes]<br />
{<br />
}<br />
## Keyword method<br />
[method, attributes]<br />
- (ReturnType)methodNamePart1:(Arg1Type)arg1 [argument, attributes] namePart2:(Arg2Type)arg2 := 0 [argument, attributes] namePart3:(Arg3Type)arg3 := 0 [argument, attributes]<br />
{<br />
}<br />
</code><br />
Each method can be preceded by an optional list of comma-separated attributes surrounded by square brackets, among attributes you can have &#8220;deprecated&#8221; or &#8220;abstract&#8221; (other attributes might come later).<br />
Arguments can also be followed by an optional square-bracket surrounded comma-separated attribute list, among attributes you can have &#8220;unused&#8221; and maybe others. In keyword messages, arguments (except the first one) can have default values, it is denoted with the assigned operator followed by a constant or an expression in parentheses. Setting a default value for an argument makes the compiler add the methods definitions automatically with the different arguments.<br />
For example, this definition:<br />
<code>- (Integer)firstArgument:(Integer)arg1 secondArgument:(Integer)arg2 := 0 thirdArgument:(Integer)arg3 := 0.</code><br />
Make the compiler create for you the following methods:<br />
<code>- (Integer)firstArgument:(Integer)arg1.<br />
- (Integer)firstArgument:(Integer)arg1 secondArgument:(Integer)arg2.<br />
- (Integer)firstArgument:(Integer)arg1 thirdArgument:(Integer)arg3.<br />
- (Integer)firstArgument:(Integer)arg1 secondArgument:(Integer)arg2 thirdArgument:(Integer)arg3.</code></p>
<p>This means you can define:<br />
<code>- (Integer)firstArgument:(Integer)arg1 secondArgument:(Float)arg2.<br />
- (Integer)firstArgument:(Float)arg1 secondArgument:(Float)arg2 := 0.<br />
</code><br />
But not:<br />
<code>- (Integer)firstArgument:(Integer)arg1 secondArgument:(Float)arg2 := 0.</code><br />
Because &#8220;- (Integer)firstArgument:(Integer)arg1&#8243; is already defined</p>
<p>Thanks to the keyword syntax there can be as much different methods as there are different keywords. You can see, in the previous definition, that I don&#8217;t need to use secondArgument: if I just want the thirdArgument. In case the keywords are the same, the keywords are filled in the order they appear. For example in this definition:<br />
<code>- (id)performSelector:(Selector)aSel withObject:(id)obj1 := nil withObject:(id)obj2 := nil.</code><br />
Generates these methods:<br />
<code>- (id)performSelector:(Selector)aSel.<br />
- (id)performSelector:(Selector)aSel withObject:(id)obj1.<br />
- (id)performSelector:(Selector)aSel withObject:(id)obj1 withObject:(id)obj2.</code><br />
The &#8220;obj1&#8243; in the second definition is the same &#8220;obj1&#8243; in the third definition. Note that you cannot reorder keywords.</p>
<h2>Property Syntax</h2>
<p>Properties usually define accessors, and if necessary also define the storage for the variable they represent. You can also provide an implementation for either or both methods of the property. Whenever you&#8217;ll do a get outside of the getter method, it will necessarily go through the method, if you do a set outside of the setter it will necessarily go through the setter method. This feature is inspired from SalesForce.com&#8217;s Apex language. The syntax is as follow:<br />
<code><br />
## default get and set all public<br />
- PropType propName1 [attributes].<br />
- PropType propName2 [attributes] { get. set. }<br />
## default public get and private set<br />
- PropType propName3 [attributes] { get. private set. }<br />
## Provide an implementation for both get and set<br />
- PropType propName4 [attributes] { get { return propName4. } set { propName4 := value. } }<br />
</code><br />
<span style="text-decoration:underline;">Note</span>: The variable &#8220;value&#8221; is the name of the setter&#8217;s argument, the method declaration is equivalent to: &#8220;<code>-(void)setPropName3:(PropType)value.</code>&#8220;.</p>
<p>Attributes can be:</p>
<ul>
<li>&#8220;<code>readonly</code>&#8220;/&#8221;<code>writeonly</code>&#8220;/&#8221;<code>readwrite</code>&#8220;: telling which methods are implemented.</li>
<li>&#8220;<code>getter=methodName</code>&#8220;: provides an alternate name to get the value of the property</li>
<li>&#8220;<code>setter=methodName:</code>&#8220;: provides an alternate name to set the value of the property (the colon is required)</li>
<li>&#8220;<code>weak</code>&#8220;/&#8221;<code>strong</code>&#8220;/&#8221;<code>copy</code>&#8220;: tells how the property behaves with the garbage collector, strong is the default, copy is a strong reference too, but calls the &#8220;-copy&#8221; method of the value.</li>
<li><code>deprecated</code></li>
</ul>
<h2>Constructors</h2>
<p>BambooTalk implements a different kind of constructors than either ObjC or C++/C#/Java. Constructors in BambooTalk is actually a mix of the two.</p>
<p>In Cocoa, you have to define, in a class, a designated initializer, and you can define any number of secondary initializers. The designated initializer is the only init of the class that will call the designated init of the super-class, and all other initializers will call the designated one. Also the class must override the designated init of its super-class to make it call its own designated init. Respecting these conventions makes subclassing easier, making sure all the class and its super-classes designated initializers are called and their ivars properly initialized. It also allows all init methods of all super-classes to be usable on your own class.</p>
<p>BambooTalk constructors retains these conventions providing a syntax to let the compiler do the repeating code. Constructors are, like in ObjC, simple class methods, they are, in fact, Class methods with a different prefix character. Each class have, at most, one designated constructor, which is a class method that starts with &#8220;<code>@</code>&#8220;, and can have any number of secondary constructors that start with the &#8220;<code>*</code>&#8221; character.</p>
<p>The designated constructor doesn&#8217;t need to explicitly call the super-class designated constructor, although you can call it explicitly using &#8220;super designatedConstructor&#8221; syntax. If you don&#8217;t call it explicitly, it will be the first statement before your own code. When you define a designated init, the super-class designated init is overrode automatically and call your own designated init with nil parameters (or default arguments, if you provide them), if you want other default you have to override it explicitly and call the designated constructor explicitly. You can name parameters the same as your ivars, in this case, you don&#8217;t need to implement the constructor if all you do is copying the values.<br />
Example:<br />
<code>## This class would usually be implemented as a struct<br />
class Range : Object<br />
{<br />
- Integer location, length.<br />
@ (self)newWithLocation:(Integer)location := 0 length:(Integer)length := 0 ## implementing is optional here<br />
{<br />
self := super new. ## reassignment is optional, calling super new is optional<br />
self location := location.<br />
self length := length.<br />
return self. ## optional<br />
}<br />
* (self)newWithRange:(Range)aRange<br />
{<br />
## return is optional.<br />
return self newWithLocation: aRange location length: aRange length.<br />
## If the designated constructor is not explicitly called it is added at the beginning of the declaration<br />
#: alternate implementation:<br />
location := aRange location.<br />
length := aRange length.<br />
:#<br />
}<br />
}</code></p>
<p>Notes:</p>
<ul>
<li>As an exception, the designated constructor&#8217;s first argument can have a default value to help the compiler generate the overridden version of the super-class designated constructor, as any other secondary constructor. However, when called explicitly, the first argument of the designated constructor is still required.</li>
<li>If the reassignment of self or the return statement are wrote explicitly in the constructor, the compiler won&#8217;t generate the calls to the designated constructors.</li>
<li>Constructors are class methods, meaning you can&#8217;t use a constructor name in another class method. The feature is really optional and allows you to let the compiler do most of the implementing work.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=39&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/15/bambootalk-typing-part-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk Typing, Part II</title>
		<link>http://remydemarest.wordpress.com/2010/01/13/bambootalk-typing-part-ii/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/13/bambootalk-typing-part-ii/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 21:33:03 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>
		<category><![CDATA[Typing]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=29</guid>
		<description><![CDATA[This article provide a first look at complex type, namely: classes and structures. However, it doesn't cover them in-deep.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=29&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this article, I will discuss complex types in BambooTalk. There are two of them: structures and classes.</p>
<h2>Complex Types</h2>
<h3>Classes</h3>
<p>Classes in BambooTalk are equivalent to Objective-C classes and retain a very close syntax, a class:</p>
<ul>
<li>can inherit from other classes, with single-inheritance;</li>
<li>can conform to any number of protocols in the manner of ObjC;</li>
<li>has properties and methods, which can have access restrictions (public, protected, package, private);</li>
<li>can have categories to add new methods;</li>
<li>by default, all properties and methods are public to a certain extent</li>
</ul>
<p>The syntax is pretty similar to ObjC classes, except for the used keywords:<br />
<code><br />
class ClassName : SuperClassName &lt;Comma, Separated, Protocol, List&gt;<br />
{<br />
    private<br />
    + Integer count. ## class property<br />
    - Integer count. ## instance property</p>
<p>    public<br />
    ## class method taking one argument (keyword message)<br />
    + (void)myMethod: (id)arg1 { Log print: arg1. }</p>
<p>    ## instance method (unary message)<br />
    - (void)myMethod { #: do something clever :# }</p>
<p>    protected<br />
    ## instance method taking one argument (binary message)<br />
    - (Integer) + (Integer)arg { return self count + arg. }<br />
}<br />
</code><br />
As you can see, like in ObjC, class methods/properties and instance methods/properties are in different namespaces and you can, without problems, define class and instance methods with same names. On the other hand, properties are in the same namespace as methods, so in this class, you can&#8217;t define <code>-(Integer)count</code> or <code>-(void)setCount:(Integer)value</code> separately outside of their property definition. However, BambooTalk supports parametric polymorphism/overloading, so you can define <code>-(void)setCount:(Float)value</code> method.</p>
<p>Note: public, protected, package and private work the same on properties and methods as they work in ObjC for ivars. The access modifier changes the nature of all declarations following it until the end of the declaration or until another modifier is found.</p>
<h3>Structures</h3>
<p>Structures are very close to classes, however there is no inheritance for structures, but they can still conform to any number of protocols. They can also define properties and methods. The lack of inheritance allows the compiler to optimize messages to structures and thus making the access more efficient. The syntax is exactly the same as classes although there is not super-class name:<br />
<code><br />
struct StructureName &lt;Comma, Separated, Protocol, List&gt;<br />
{<br />
    private<br />
    + Integer count. ## class property<br />
    - Integer count. ## instance property<br />
    public<br />
    ## class method taking one argument (keyword message)<br />
    + (void)myMethod: (id)arg1 { Log print: arg1. }</p>
<p>    ## instance method (unary message)<br />
    - (void)myMethod { #: do something clever :# }<br />
    protected<br />
    ## instance method taking one argument (binary message)<br />
    - (Integer) + (Integer)arg { return self count + arg. }<br />
}</code><br />
You can see that you can also have class and instance properties/methods in a structure type.<br />
<span style="text-decoration:underline;"> Note</span>: Structure names lie in the same namespace as class names.</p>
<p>This conclude the article. In the next article, I will discuss features shared by both complex types: properties, constructors, etc.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=29&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/13/bambootalk-typing-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk Typing, Part I</title>
		<link>http://remydemarest.wordpress.com/2010/01/13/bambootalk-typing-part-i/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/13/bambootalk-typing-part-i/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 20:38:42 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>
		<category><![CDATA[Typing]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=26</guid>
		<description><![CDATA[In this articles, we'll see the "simple types" defined by BambooTalk language.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=26&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the main goals of BambooTalk, compared to SmallTalk and Objective-C, is to provide a stricter compile-time typing, to prevent developer errors as early as possible, and thus avoiding that untested branches of the code crashes while the application is released.</p>
<p>BambooTalk actually defines two typing systems: typing is both static and dynamic, while at runtime every message is dispatched dynamically like in SmallTalk and ObjC, you can help the compiler in helping you debugging your code more easily by using static typing. Static typing works the same as in ObjC, you give a specific type to a variable, the compiler will always consider that this variable will have the same type at runtime and thus will respond to selectors of this type, allowing the compiler to check whether you&#8217;re sending messages to an object that doesn&#8217;t respond to it.</p>
<p>The improvement, compared to ObjC, will be the possibility to override methods in subclasses and provide a return type that is a subclass of the return type in the super-class, without making the compiler shout about type mismatch. BambooTalk will also include type inference, for example a method having the return type &#8220;self&#8221;, or taking &#8220;self&#8221; as an argument, will be considered as returning the type of the receiver, even if it&#8217;s not the actual receiver that is returned. Another improvement is generics, BambooTalk will provide generics as a mean to enforce object types. For example, you could say that an array can only accept objects of type Integer. I will discuss these features in the next articles.</p>
<h2>The Type Families</h2>
<p>There are two kinds of types: simple and complex types. Complex types are discussed in <strong>Part 2</strong>. Among complex types you have structures and classes, and among simple types you have enumerations (equivalent to enum in C), product (equivalent to struct in C) and sum (equivalent to union in C). The difference between the two kinds is that complex types have properties and methods, whereas simple types only have attributes.</p>
<h2>Simple Types</h2>
<p>As Lolcats would say, &#8220;simpel typs R simpel&#8221;. They are easy to construct and have a simple syntax. Sum and product type can even be constructed on the fly where they are used. Enumerations on the other hand are preferably defined at one specific place and define constants, like in C. The other difference is that enums have an explicit type name whereas the sum and product types don&#8217;t require it.</p>
<h3>Enumerations</h3>
<p>Enumerations have the same syntax as in C and the same behavior:</p>
<ul>
<li>They represent integers;</li>
<li>By default, they start at 0;</li>
<li>By default, the value of subsequent constants is incremented by 1;</li>
<li>You can force the value of the constant using the assign operator.</li>
</ul>
<p>The syntax is equivalent to C&#8217;s (minus the required end-of-statement marker after it):<br />
<code>enum EnumName<br />
{<br />
    value1,       ## implicitly set to zero<br />
    value2 := -2, ## explicitly set to -2<br />
    value3,       ## implicitly set to -1, the last comma is neither required nor an error<br />
}</code><br />
You can access an enumeration constants by using message syntax on the type, like a property, for example: &#8220;<code>myVar := EnumName value1.</code>&#8220;. This syntax is inspired from C#, the advantage is that it encapsulates each constant names into its own namespace, allowing one to reuse the name in other enums or even as types. The other advantage is that it helps in type checking removing ambiguities. Enum being integers there is no restriction as for assigning them to number variables.</p>
<h3>Product Types</h3>
<p>Product types are equivalent to C structures. They can store multiple variables of various types in one logical group. They are especially useful for return types as they provide a way to return multiple variables at once. The syntax is as follow:<br />
<code>{ type1 var1, var2. type2 var3. }</code><br />
<span style="text-decoration:underline;">Note</span>: there is no explicit name for the structure, I will show later how to provide one. Just like enumerations and classes, the members of the product are accessible using the message syntax:<br />
<code>{ type1 var1, var2. type2 var3. } v.<br />
v var1 == v var2.<br />
v setVar1: value.<br />
</code><br />
<span style="text-decoration:underline;">Note</span>: the setter uses the variable name with a capital letter. You can also use the assignment operator: &#8220;<code>v var1 := value.</code>&#8220;.</p>
<h3>Sum types</h3>
<p style="text-align:left;">Sum types are equivalent to C unions, however they can represent only one type at a time. The construction is only composed of types separated by a bar &#8220;|&#8221;, example: &#8220;<code>{ type1 | type2 | type3 }</code>&#8220;. This type is also useful in return types: a method can return nothing if it succeeded; or an error object that contains a description of the problem that occurred. How the type is tested or how the value is recovered is yet to be defined.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=26&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/13/bambootalk-typing-part-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk expressions and control structures</title>
		<link>http://remydemarest.wordpress.com/2010/01/13/bambootalk-expressions-and-control-structures/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/13/bambootalk-expressions-and-control-structures/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 08:13:47 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=19</guid>
		<description><![CDATA[In this article I present the language expressions, control structures as well as the binary operator, the cascading message and comment syntaxes.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=19&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to a new episode of BambooTalk, this time I&#8217;m going to talk about the basic bricks of the language: comments, expressions, control structures, the assignment operator and cascading messages. I will talk about types in the next articles.</p>
<h2>Comments</h2>
<p>There are, like in ObjC, two kinds of comments, block comments (like in ANSI-C) and line comments (like in BCPL/ObjC/C99&#8230;) :</p>
<ul>
<li>Line comments start with two colons &#8216;<code>##</code>&#8216; and runs until the end of the line,</li>
<li>Block comments start with colon and hash signs &#8216;<code>#:</code>&#8216; and finish with hash and colon signs &#8216;<code>:#</code>&#8216;, comments can be nested and distributed over multiple lines.</li>
</ul>
<p>All commented text is, obviously, ignored by the compiler. I chose not to use C-like <code>//</code> and <code>/* */</code> because they represent valid binary messages, colon and hash signs aren&#8217;t valid binary message characters. For your information, SmallTalk uses double-quoted strings as comments: <code>"this is a comment"</code>, though I prefer keeping this syntax for normal strings.</p>
<h2>Expressions</h2>
<p>In BambooTalk, every time you use a semicolon in C-like languages you will use a period &#8216;.&#8217;. Periods end a statement in BambooTalk just like they do in SmallTalk, this is because it&#8217;s closer to human languages and also because I find it nice. The semicolon, on the other hand is used for cascading messages, another nice feature from SmallTalk which I will talk about later.</p>
<h2>Control structures</h2>
<p>BambooTalk retains most construction from C-like languages:</p>
<ul>
<li>Conditions:<br />
<code>if(condition)<br />
#: statements :#<br />
else if(condition)<br />
## statements<br />
else<br />
## statements<br />
</code></li>
<li>Loops:
<ul>
<li><code>while(condition)<br />
{ #: statements :# }</code></li>
<li><code>do<br />
{ #: statements :# }<br />
while(condition).</code></li>
<li><code>for(initialize . condition . increment)<br />
{ #: statements :# }<br />
</code></li>
</ul>
</li>
<li>Switch (for now it&#8217;s defined like in C, but might change in the future):<br />
<code>switch(expression)<br />
{<br />
case value : ##statements<br />
case value : #: statements :# break.<br />
default : #: statements :# break.<br />
}<br />
</code></li>
<li>Collection iterations:<br />
<code>foreach(variable in collection)<br />
{ #: statements :# }</code></li>
<li>Keyed/Indexed collection iterations:<br />
<code>foreach(value_variable at key_or_index_variable in collection)<br />
{ #: statements :# }</code></li>
</ul>
<p>Other control structure can be added in the future. BambooTalk being a whole new language nothing prevents it from defining new keywords, I take advantage of this fact to introduce C#&#8217;s &#8220;<code>foreach</code>&#8221; construction and improve it a little bit. ObjC 2.0 defines the same construction, but uses the already existing &#8220;for&#8221; keyword from C to avoid the need of reserving an ugly &#8220;<code>__foreach</code>&#8221; keyword, like they did for &#8220;<code>__block</code>&#8220;.</p>
<p>So, BambooTalk defines &#8220;<code>foreach(variable in collection) { #: statements :# }</code>&#8221; which can iterate through any collection conforming to the fast enumeration protocol (yet to be defined) equivalent to ObjC 2.0&#8242;s.<br />
It also defines the &#8220;<code>foreach(value_variable at key_or_index_variable in collection) { #: statements :# }</code>&#8221; construction equivalent to PHP&#8217;s &#8220;<code>foreach (array_expression as $key =&gt; $value)</code>&#8220;, which can iterate in any indexed or keyed collections, so it excludes set iterations. Any object conforming to the fast keyed enumeration protocol can be used with this foreach.</p>
<p>Along with those control structures, BambooTalk defines, like C-like languages, &#8220;<code>break</code>&#8221; to stop the execution of a loop or the flow of instruction in a switch, &#8220;<code>continue</code>&#8221; to go to the next iteration of a loop and &#8220;<code>return</code>&#8221; to stop the execution of a method and return control to the caller.</p>
<h2>The sole actual operator of BambooTalk</h2>
<p>As seen before, in BambooTalk &#8220;operators&#8221; aren&#8217;t operators but actual messages, in fact, BambooTalk only defines one operator. This operator is the assignment operator and is represented as a colon followed by an equal sign: &#8220;<code>:=</code>&#8220;. It is NOT inspired from Pascal (which I never touched) but from SmallTalk, which defines two operators, this one, and the return operator &#8220;<code>^</code>&#8220;.</p>
<p>This operator is evaluated from right to left, the value of the expression on the right is assigned to the variable defined on the left:<br />
Example: <code>a := b := c. ## the value of c is assigned to b and the value of b is assigned to a.</code></p>
<p>As I was thinking about the language design, a major C-user problem hit me: C reassign operators (like +=) are still valid messages in BambooTalk! The receiver of the message is passed as a reference to the message, so I wouldn&#8217;t be able to transform this statement &#8220;a += b;&#8221; into this &#8220;a = a + b;&#8221; without breaking the language coherence: the reference doesn&#8217;t allow the &#8220;variable&#8221; receiver to be changed from within the call (in ObjC, reassigning self does not affect the caller&#8217;s code), and enforcing special cases in the compiler is not an option (it&#8217;s ugly, error-prone and uselessly complex for nothing). So, to solve this problem, I thought about a new syntax for the language that would add more flexibility than normal reassign operators, and keep coherence of the language:</p>
<p>The reassignment syntax is as follow, &#8220;variable assign_op binary_message expression&#8221;.</p>
<p>For example: <code>a := + b.</code> is equivalent to <code>a := a + b.</code>, the left operand is required to be a variable. Although the binary message represents a message, it will be evaluated last, for example &#8220;a := * b + c&#8221; would be transformed into &#8220;a := a * (b + c)&#8221; and not &#8220;a := (a * b) + c&#8221; as the messaging syntax usually suggests.</p>
<p>And last, but not least, due to right-to-left evaluation of (re)assignment operator, expressions containing multiple assignment operators are also evaluated from right to left.<br />
Example: <code>a := + b - c := * d + e.</code> the first expression being evaluated is &#8220;<code>d + e</code>&#8221; then &#8220;<code>c * (d + e)</code>&#8221; reassigned to &#8220;<code>c</code>&#8220;, and then &#8220;<code>a := + b - c</code>&#8221; is evaluated.</p>
<h2>Cascading messages</h2>
<p>To finish with this article, I will talk about a nice feature from SmallTalk that I absolutely wanted in BambooTalk: cascading messages. The principle of cascading messages is about sending multiple messages to one receiver in the same expression. Only the first message of the cascading list has an explicit receiver, and all the other messages that follow uses the same receiver. The result of a cascading message is the result of the last message in the cascade: if previous messages return a value, this value is simply ignored, only the last return value counts. Cascaded messages are separated by semicolons.<br />
Example: &#8220;<code>a b; c; d; e; f.</code>&#8221; this expression contains 5 messages and one receiver. The first message is &#8220;b&#8221; and its receiver is &#8220;a&#8221;, then each messages are sent to the same receiver. So, &#8220;a&#8221; receives sequentially the messages &#8220;b&#8221;, &#8220;c&#8221;, &#8220;d&#8221;, &#8220;e&#8221; and &#8220;f&#8221;, also the whole expression evaluates to the last message&#8217;s return value: on the caller&#8217;s point of view, the whole expression is equivalent to &#8220;a f.&#8221;, that is the message &#8220;f&#8221; sent to receiver &#8220;a&#8221;. Of course, if intermediate &#8220;b&#8221;, &#8220;c&#8221;, &#8220;d&#8221; and &#8220;e&#8221; messages were not doing anything, it would be useless to chain them.<br />
Any kind of message can be used in cascading messages, for example: &#8220;<code>a := 10. b := a + 5; * 4; - 1.</code>&#8221; would assign the value 9 to &#8220;b&#8221; because &#8220;a &#8211; 1&#8243; equals 9 and the return values of messages &#8220;+ 5&#8243; and &#8220;* 4&#8243; are simply ignored.</p>
<p>This construction is very useful as an alternative to big constructors, for example instead of &#8220;<code>r := Rect newWithX: 0 y: 0 width: 10 height: 100.</code>&#8220;, you can use the cascading messages as follow: &#8220;<code>r := Rect new setWidth: 10; setHeight: 100; self.</code>&#8220;. Note that the last message in the cascade is &#8220;self&#8221;, as I said before, the result of the whole cascading expression is the result of the last message: without self, the last message would be &#8220;setHeight:&#8221; which, like any setter, returns void, the result of the whole expression would be void, which is not suitable for an assignment. This is why &#8220;self&#8221;, that simply returns the receiver, is the last message in the cascade, so the result of the whole expression is the object we allocated at the beginning, namely the result of &#8220;Rect new&#8221;, and thanks to cascading messages, this instance also received &#8220;setWidth:&#8221; and &#8220;setHeight:&#8221; messages with 10 and 100 as arguments.</p>
<p>Some of those features might be difficult to understand, some of them might look weird, and some others are still in thinking process. Any comment, question or suggestion is welcomed. Thank you for reading.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=19&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/13/bambootalk-expressions-and-control-structures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk messages</title>
		<link>http://remydemarest.wordpress.com/2010/01/12/bambootalk-messages/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/12/bambootalk-messages/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 18:40:57 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=11</guid>
		<description><![CDATA[In this article, I&#8217;m going to talk about messages in BambooTalk. As I said before, this language is based on both SmallTalk and Objective-C. The former has quite a simple philosophy: everything is an object, if it&#8217;s not an object it&#8217;s a message. And the latter OO model is actually the same as SmallTalk with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=11&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this article, I&#8217;m going to talk about messages in BambooTalk.</p>
<p>As I said before, this language is based on both SmallTalk and Objective-C. The former has quite a simple philosophy: everything is an object, if it&#8217;s not an object it&#8217;s a message. And the latter OO model is actually the same as SmallTalk with the difference that it also retains compatibility with C.</p>
<p>BambooTalk philosophy should then be equivalent, I&#8217;ve retained a lot of nice stuff from SmallTalk and kept some from C/ObjC to prevent this language to become too alien.</p>
<p>Let&#8217;s start with messages. Messages are equivalent to method/member function calls in C++/Java/C#. In SmallTalk and ObjC, and thus in BambooTalk, a &#8220;message&#8221; is sent to a &#8220;receiver&#8221;, if the receiver can respond to the message it will return an &#8220;answer&#8221;. The &#8220;selector&#8221; of a message is an identifier that will be used by the runtime to find the receiver&#8217;s method implementation attached to the sent message, the selector is simply the name of the method.</p>
<p>BambooTalk keeps the 3 different kinds of messages from SmallTalk, namely: unary, binary and keyword messages.</p>
<p>Unary messages: they take the form of a simple identifier and have no arguments.<br />
Example: &#8220;obj message&#8221;, here the unary message &#8220;message&#8221; is sent to the receiver &#8220;obj&#8221;.</p>
<p>Keyword messages: it&#8217;s the form that disorient most ObjC newcomers, but it is also a very nice auto-documenting message construction. It takes the form of a list of &#8220;keywords&#8221; representing the subparts of the message name, and each keyword is followed by an argument, a keyword is simply an identifier directly followed by a colon.<br />
Example: &#8220;obj setValue: v forKey: k&#8221;, here the keyword message &#8220;setValue:forKey:&#8221; (colons are included in the name) is sent to the receiver &#8220;obj&#8221; with the arguments &#8220;v&#8221; and &#8220;k&#8221;.</p>
<p>Binary message: I put this one in the last position because it&#8217;s a nice feature of SmallTalk that may be confusing for C/C++/ObjC/Java developers. A binary message is simply a message taking one and only one argument, and the selector of the message uses only a special restricted set of characters: &#8220;~ ! @ % &amp; * &#8211; + = | \  &lt; &gt; , ? / ^ `&#8221;.<br />
As you can see here, binary messages look a lot like operators, but they really are messages, and they can be any combination of characters in this set, nothing prevents you from inventing your own &#8220;operators&#8221;, for example &#8220;~!&amp;&amp;//\\?^&#8221; is a valid binary message selector, I have no idea what it does though.<br />
Although they look a lot like operators, they really are messages and since the receiver, like for all messages, is always on the left, they&#8217;re evaluated from left to right, which makes this calculus: &#8220;3 + 2 * 5&#8243; equal to 25 and not 13, because this is equivalent to &#8220;(3 + 2) * 5&#8243; and not &#8220;3 + (2 * 5)&#8221;. In one word, there is no precedence between binary messages; to force precedence, however, parentheses can be used, as in the two examples before.</p>
<p>There is no operator precedence between messages of the same kind, all messages are evaluated from left to right, but there is a precedence between message kinds. Parenthesized expressions are evaluated first, then come unary messages, followed by binary messages and then keyword messages, which allows you to nest unary messages into keyword message arguments or as a receiver.</p>
<p>Example: MyClass new + t setValue: obj copy not / z forKey: k &#8211; k1 * c. I have no idea what that code does, yours to find a signification, though I know how it is evaluated:</p>
<ul>
<li>&#8220;new&#8221; message is sent to &#8220;MyClass&#8221;</li>
<li>&#8220;+&#8221; message is sent to the answer of the &#8220;MyClass new&#8221; message with &#8220;t&#8221; as argument</li>
<li>&#8220;copy&#8221; message is sent to &#8220;obj&#8221;</li>
<li>&#8220;not&#8221; message is sent to the answer of &#8220;obj copy&#8221;</li>
<li>&#8220;/&#8221; message is to the answer of &#8220;obj copy not&#8221; with the argument &#8220;z&#8221;</li>
<li>&#8220;-&#8221; message is sent to &#8220;k&#8221; with the argument &#8220;k1&#8243;</li>
<li>&#8220;*&#8221; message is sent to the answer of &#8220;k &#8211; k1&#8243; with the argument &#8220;c&#8221;</li>
<li>&#8220;setValue:forKey:&#8221; message is sent to the answer of &#8220;MyClass new + t&#8221; with the answers of &#8220;obj copy not / z&#8221; and &#8220;k &#8211; k1 * c&#8221; messages as arguments.</li>
</ul>
<p>This weird expression shows one particular thing: you can chain as much unary and binary messages as you wish but you cannot chain keyword messages without parentheses. Indeed, if you write: &#8220;obj setValue: v forKey: k index: i&#8221; the message will be &#8220;setValue:forKey:index:&#8221;, whereas &#8220;(obj setValue: v forKey: k) index: i&#8221; the messages will be &#8220;setValue:forKey:&#8221; and &#8220;index:&#8221;.<br />
This is a limitation enforced by the nature of the keyword messages: how can you tell this expression &#8220;obj setValue: v forKey: k index: i&#8221; is the message &#8220;index:&#8221; sent to the answer of the message &#8220;forKey:&#8221; sent to the answer of the message &#8220;setValue:&#8221;, and not the message &#8220;index:&#8221; sent to the answer of &#8220;setValue:forKey:&#8221; or the message &#8220;setValue:forKey:index:&#8221; sent to &#8220;obj&#8221; ? Well, KISS principle applied, as well as in SmallTalk, keyword messages need to be parenthesized to be chained because a sequence of keywords in an expression will be considered as part of the same message.</p>
<p>With these three kinds of messages, the developer is provided pretty good tools to make an easily readable code: unary and keyword messages can retain their auto-documenting properties that are extensively used in Cocoa, and binary messages gives more flexibility than operator overloading in other languages.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=11&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/12/bambootalk-messages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
		<item>
		<title>BambooTalk introduction</title>
		<link>http://remydemarest.wordpress.com/2010/01/12/bambooktalk-introduction/</link>
		<comments>http://remydemarest.wordpress.com/2010/01/12/bambooktalk-introduction/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 05:27:30 +0000</pubDate>
		<dc:creator>Remy Demarest</dc:creator>
				<category><![CDATA[BambooTalk]]></category>

		<guid isPermaLink="false">http://remydemarest.wordpress.com/?p=5</guid>
		<description><![CDATA[Okay for my first real message, I&#8217;m going to present the main personal project I&#8217;m working on. This is yet another object-oriented language, I sincerely think there is not enough languages out there so I wanted to add mine&#8230; No seriously, that&#8217;s not the reason. This project started a long time ago in a galaxy [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=5&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Okay for my first real message, I&#8217;m going to present the main personal project I&#8217;m working on.</p>
<p>This is yet another object-oriented language, I sincerely think there is not enough languages out there so I wanted to add mine&#8230; No seriously, that&#8217;s not the reason.</p>
<p>This project started a long time ago in a galaxy far far away (in my head), some time between 1 or 2 years ago. In the beginning, it was just something to have fun as I had fun implementing a Lisp interpreter in ObjC/Cocoa, but then it became more concrete when I thought about its actual goals:</p>
<p>I am a true fan of Objective-C and Cocoa, to me they are the best languages and frameworks out there&#8230; You agree or not, that&#8217;s not the point, a lot other frameworks and languages have good ideas and are nicely designed, but to me, the one that is the most well-designed is ObjC/Cocoa. But during my wanderings on the internet or outside, I&#8217;ve heard a lot of criticisms about ObjC or Cocoa, some would piss me off (features asked by users that would come from C++), some of them were justified (loose typing, too many brackets for example), and I have mine as well (the non-flexible imposed C base). Hence my first goal for this language was to address those criticisms in mine and keep all the nice stuff of ObjC.</p>
<p>So, I started designing something, it was called Objective-Psy (yes I&#8217;m Humble) and was kinda just ObjC without the C part that was annoying and some more strict typing&#8230; But it mostly kept ObjC existing stuffs, including functions, multiple different base types, .h/.m pairs, @keywords, [bracket messages], etc. Not very fun&#8230;</p>
<p>Then came Landon Fuller, founder of Plausible Labs, who has, among other things, ported Blocks to Mac OS X Leopard and iPhone (based on some rudimentary Blocks runtime I made). Landon proposed me to work with him on a new language that would also address some of the problems of ObjC; his biggest concern about it was typing: it is either too loose or too tight, he prefers some strict typing, having the compiler telling him he&#8217;s doing it wrong and not the runtime. Fair enough, that&#8217;s not something that bothers me much, all I want is keeping ObjC dynamism which is its biggest strength and also the keyword-method syntax (initWithFirstName:lastName:).</p>
<p>So here we start working on designing the language: BambookTalk, with his compile-time typing and functional background and my runtime typing and object-oriented background, we did some good work together that we put in <a title="Bamboo-language Google Code webpage" href="http://code.google.com/p/bamboo-language/">here</a>. We looked back at the roots of ObjC and dug into SmallTalk, the first OO language that was qualified as is. It is a really pure and extremely dynamic language, to the point that you can modify your IDE whilst running it to perform the change&#8230; Though the typing is full-runtime, the syntax is very nice, except when defining classes in separate text files for archiving&#8230; So then we looked a little at StrongTalk, which is SmallTalk with &#8220;strong&#8221; compile-time typing and some other languages like Newspeak&#8230; We ended up wanting to build a love-child of SmallTalk and ObjC, so we started to put some proposals available in the project&#8217;s wiki; but then the project lost some attention due to lack of time mostly.</p>
<p>It was 1 or 2 months ago since I decided to get my hands dirty to work on a compiler to have clearer ideas on how to construct the languages. I think I&#8217;ve came up with a pretty nice language so far, some stuff may seem weird because I tried to keep the language as coherent and simple as possible, however the language itself comes up nice, in my humble opinion.</p>
<p>So for now, the language is still a (love-?)child of SmallTalk and ObjC, most of its features come from those two languages, some others are inspired from other languages as well&#8230; The language includes namespaces, classes, enums, public/protected/package/private class/instance properties/methods, constructors, garbage-collection, generics, strong compile-time/runtime typing, reflection, parametric/polymorphism overloading, &#8220;operators&#8221; overloading and a very nice SmallTalkish message syntax. I will expose all of that in future articles.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/remydemarest.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/remydemarest.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/remydemarest.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/remydemarest.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/remydemarest.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/remydemarest.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/remydemarest.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/remydemarest.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/remydemarest.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/remydemarest.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/remydemarest.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/remydemarest.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/remydemarest.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/remydemarest.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=remydemarest.wordpress.com&amp;blog=11377364&amp;post=5&amp;subd=remydemarest&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://remydemarest.wordpress.com/2010/01/12/bambooktalk-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9da021619c0eac198d5b6148868aa791?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychoh13</media:title>
		</media:content>
	</item>
	</channel>
</rss>
