|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Quick QuestionsIs it possible to implement 'break' and 'continue' in Io?
Should 'break' and 'continue' be considered operators? Should 'return' be referred to as a "method"? ("Any part of a block can return immediately using the return method") Is it necessary to give 'return' special syntax? How can one create user-defined operators? ["User defined operators (that don't have a standard operator name) are performed left to right."] It's not immediately obvious how special 'keywords' and operators are handled. For instance: Io> and := 1 ==> 1 Io> 1 + and ==> 2 Io> and + 1 ==> 1 Io> and + 100 ==> 1 Io> and + and ==> 1 Also: Io> and := false ==> false Io> and or 1 ==> false Also: Io> return := 1 ==> 1 Io> 1 + return ==> 2 Io> return + 1 ==> 1 strange, but consistent: (I imagine IDs/addresses are being compared; 'true' must be created before 'false', an unsafe assumption some programmer could use): Io> true < false ==> true Io> false < true ==> false Io> true > false ==> false Io> false > true ==> true Also, there is more special treatment: Io> false := true ==> true Io> false ==> false Shouldn't 'true' and 'false' be slots of Lobby? Thanks for your help, Michael Witten |
|
|
Re: Quick QuestionsIt is, see the stopStatus stuff.
-- Jeremy Tregunna jtregunna@... On 10-Jun-08, at 2:32 AM, Michael Witten wrote: > Is it possible to implement 'break' and 'continue' in Io? > > Should 'break' and 'continue' be considered operators? > > Should 'return' be referred to as a "method"? > ("Any part of a block can return immediately using the return method") > > Is it necessary to give 'return' special syntax? > > How can one create user-defined operators? > ["User defined operators (that don't have a standard operator name) > are > performed left to right."] > > It's not immediately obvious how special 'keywords' and operators are > handled. For instance: > > Io> and := 1 > ==> 1 > Io> 1 + and > ==> 2 > Io> and + 1 > ==> 1 > Io> and + 100 > ==> 1 > Io> and + and > ==> 1 > > Also: > > Io> and := false > ==> false > Io> and or 1 > ==> false > > Also: > > Io> return := 1 > ==> 1 > Io> 1 + return > ==> 2 > Io> return + 1 > ==> 1 > > strange, but consistent: > (I imagine IDs/addresses are being compared; > 'true' must be created before 'false', an > unsafe assumption some programmer could use): > > Io> true < false > ==> true > Io> false < true > ==> false > Io> true > false > ==> false > Io> false > true > ==> true > > Also, there is more special treatment: > > Io> false := true > ==> true > Io> false > ==> false > > Shouldn't 'true' and 'false' be slots of Lobby? > > Thanks for your help, > Michael Witten > > ------------------------------------ > > Yahoo! Groups Links > > > |
|
|
Re: Quick Questions> On 10-Jun-08, at 2:32 AM, Michael Witten wrote:
> >> Is it possible to implement 'break' and 'continue' in Io? >> >> Should 'break' and 'continue' be considered operators? >> >> Should 'return' be referred to as a "method"? >> ("Any part of a block can return immediately using the return >> method") >> >> Is it necessary to give 'return' special syntax? >> >> How can one create user-defined operators? >> ["User defined operators (that don't have a standard operator name) >> are >> performed left to right."] >> >> It's not immediately obvious how special 'keywords' and operators are >> handled. For instance: >> >> Io> and := 1 >> ==> 1 >> Io> 1 + and >> ==> 2 >> Io> and + 1 >> ==> 1 >> Io> and + 100 >> ==> 1 >> Io> and + and >> ==> 1 >> >> Also: >> >> Io> and := false >> ==> false >> Io> and or 1 >> ==> false >> >> Also: >> >> Io> return := 1 >> ==> 1 >> Io> 1 + return >> ==> 2 >> Io> return + 1 >> ==> 1 >> >> strange, but consistent: >> (I imagine IDs/addresses are being compared; >> 'true' must be created before 'false', an >> unsafe assumption some programmer could use): >> >> Io> true < false >> ==> true >> Io> false < true >> ==> false >> Io> true > false >> ==> false >> Io> false > true >> ==> true >> >> Also, there is more special treatment: >> >> Io> false := true >> ==> true >> Io> false >> ==> false >> >> Shouldn't 'true' and 'false' be slots of Lobby? >> >> Thanks for your help, >> Michael Witten > > On 10 Jun 2008, at 5:25 AM, Jeremy Tregunna wrote: > It is, see the stopStatus stuff. I had a few more questions. Sincerely, Michael Witten |
|
|
Re: Quick QuestionsOn 10-Jun-08, at 2:32 AM, Michael Witten wrote:
> Is it possible to implement 'break' and 'continue' in Io? > > Should 'break' and 'continue' be considered operators? > > Should 'return' be referred to as a "method"? > ("Any part of a block can return immediately using the return > method") > > Is it necessary to give 'return' special syntax? According to the below, 'break' and 'continue' are not operators, but 'return' is. (Presumably it's treated as a binary operator whose implementation simply ignores the left operand.) Io 20080120 Io> OperatorTable ==> OperatorTable_0x348360: Operators 0 ? @ @@ 1 ** 2 % * / 3 + - 4 << >> 5 < <= > >= 6 != == 7 & 8 ^ 9 | 10 && and 11 or || 12 .. 13 %= &= *= += -= /= <<= >>= ^= |= 14 return Assign Operators ::= newSlot := setSlot = updateSlot To add a new operator: OperatorTable addOperator("+", 4) and implement the + message. To add a new assign operator: OperatorTable addAssignOperator("=", "updateSlot") and implement the updateSlot message. |
| Free Forum Powered by Nabble | Forum Help |