User Tools

Site Tools


at:tutorial:basic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:basic [2007/04/06 08:25] – Adding elisagat:tutorial:basic [2007/04/06 08:31] – * elisag
Line 163: Line 163:
  
 This example also illustrates how a function can make public some of its local fields or functions by returning them as its return value. The get and set could be then passed as arguments to other functions such as //trustedFunction(get,set)// and  //distrustedFunction(get)// This example also illustrates how a function can make public some of its local fields or functions by returning them as its return value. The get and set could be then passed as arguments to other functions such as //trustedFunction(get,set)// and  //distrustedFunction(get)//
- 
- 
- 
  
 ===== Blocks ===== ===== Blocks =====
Line 196: Line 193:
 >>3 >>3
 </code> </code>
-Keywords+ 
 +===== Keywords ===== 
  
 AmbientTalk supports keyword messages. We have already seen some examples of keyword messages in the previous sections such as the foreach structure. In AmbientTalk keywords are transformed by the parser into functions in the form: AmbientTalk supports keyword messages. We have already seen some examples of keyword messages in the previous sections such as the foreach structure. In AmbientTalk keywords are transformed by the parser into functions in the form:
 +<code>
 def foo: arg1 bar: arg2 {...} def foo: arg1 bar: arg2 {...}
 def foo:bar:(arg1,arg2){..} def foo:bar:(arg1,arg2){..}
 +</code>
  
 ===== Native Data Types ===== ===== Native Data Types =====
Line 254: Line 253:
 >"ambienttalk".explode() >"ambienttalk".explode()
 >>["a", "m", "b", "i", "e", "n", "t", "t", "a", "l", "k"] >>["a", "m", "b", "i", "e", "n", "t", "t", "a", "l", "k"]
->"one, two, three".split(", ")+>"one, two, three".split(",")
 >>["one", "two", "three"] >>["one", "two", "three"]
->"ambienttalk".replace: "[aeiou]" by: { |vowel| vowel.toUpperCase() }+>"ambienttalk".replace: "[aeiou]" by: { 
 + |vowel| vowel.toUpperCase()  
 +}
 >>"AmbIEnttAlk" >>"AmbIEnttAlk"
 >"A".toLowerCase() >"A".toLowerCase()
Line 274: Line 275:
 ==== Tables ==== ==== Tables ====
    
 +TODO!
  
 ==== Booleans ==== ==== Booleans ====
Line 301: Line 303:
  
 Boolean infix operators such as & and | are not shortcut. Thus, both arguments will be evaluated. For lazy evaluation, you should use the natives methods. For example, false.and: { 1/0 } will return false without executing the second argument. Boolean infix operators such as & and | are not shortcut. Thus, both arguments will be evaluated. For lazy evaluation, you should use the natives methods. For example, false.and: { 1/0 } will return false without executing the second argument.
- 
  
 ===== Control Flow Structures ===== ===== Control Flow Structures =====
Line 322: Line 323:
      def pivot := table[(left+right) /- 2];      def pivot := table[(left+right) /- 2];
      def save := nil;      def save := nil;
-     while: { left <= right } do: {+        while: { left <= right } do: {
      while: { cmp(table[left], pivot) } do: {       while: { cmp(table[left], pivot) } do: { 
                 left := left + 1                  left := left + 1 
at/tutorial/basic.txt · Last modified: 2020/02/09 22:05 by elisag