Smalltalk-style syntax

From Erights

(Difference between revisions)
Jump to: navigation, search
(verb mapping notes)
(Verb mapping: expand verb mapping table of examples per new thinking)
 
(One intermediate revision not shown)
Line 44: Line 44:
! Arity
! Arity
|-  
|-  
-
| recip verb
+
| recip foo
-
| "verb"  
+
| "foo"  
| 0
| 0
|-  
|-  
-
| recip verb: arg  
+
| recip foo: arg  
-
| "verb"  
+
| "foo"  
| 1
| 1
|-  
|-  
-
| recip verb: arg and: arg
+
| recip foo: arg bar: arg
-
| "verb:and"
+
| "foo:bar"
| 2
| 2
 +
|-
 +
| recip foo: arg : arg
 +
| "foo"
 +
| 2
 +
|-
 +
| recip foo: arg bar: arg baz: arg
 +
| "foo:bar:baz"
 +
| 3
 +
|-
 +
| recip foo: arg bar: arg : arg
 +
| "foo:bar"
 +
| 3
|}
|}
-
The traditional Smalltalk/ObjC form would include the colon in the 1-arg verb, but this would drop it for compatibility with normal E protocols.
+
The traditional Smalltalk/ObjC form would include an additional colon at the end of the >0-arg verbs, but this would drop it for compatibility with normal E protocols.
There would also need to be a way to use arbitrary verbs as normal [[E surface syntax]] provides (the "[[verb-string]]" syntax).
There would also need to be a way to use arbitrary verbs as normal [[E surface syntax]] provides (the "[[verb-string]]" syntax).
[[Category:Syntax]]
[[Category:Syntax]]

Latest revision as of 05:12, 19 February 2008

User:Kevin Reid's idle speculation on an alternate surface syntax for E.

Translated mint example:

makeMint does {
  run: name = the any {
    [sealer, unsealer] = makeBrandPair run: name.
    mint does {
        __printOn: out = the void {
            out print: `<$name's mint>`.
        }
 
        makePurse: var balance an (int >= 0) = the any {
            decr does {
                run: amount an (0..balance) = the void {
                    set balance = balance - amount.
                }
            }.
            purse does {
                __printOn: out = the void {
                    out print: `<has $balance $name bucks>`.
                }
                getBalance = the int { balance }
                sprout     = the any { mint makePurse: 0 }
                getDecr    = the any { sealer seal: decr }

                deposit: amount an int  from: src = the void {
                    (unsealer unseal: src getDecr) run: amount.
                    set balance = balance + amount.
                }
            }.
            ^ purse
        }
    }.
    ^ mint
  }
}

Verb mapping

Syntax Verb Arity
recip foo "foo" 0
recip foo: arg "foo" 1
recip foo: arg bar: arg "foo:bar" 2
recip foo: arg : arg "foo" 2
recip foo: arg bar: arg baz: arg "foo:bar:baz" 3
recip foo: arg bar: arg : arg "foo:bar" 3

The traditional Smalltalk/ObjC form would include an additional colon at the end of the >0-arg verbs, but this would drop it for compatibility with normal E protocols.

There would also need to be a way to use arbitrary verbs as normal E surface syntax provides (the "verb-string" syntax).

Personal tools
more tools