Search the web
Sign In
New User? Sign Up
OSCAR-PROJECT · OSCAR is an open source REBOL interpreter
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
PRIMO Straw Poll / New Op! 's   Message List  
Reply | Forward Message #1011 of 1031 |
PRIMO STRAW POLL / New Op!'s

Question:
Should paren!'s be necessary to enforce
correct evaluation order in PRIMO when
using infix operators?


examples of preferable behaviour?

>> a: 4
== 4
>> print (a + 2)
6
== unset
>> a:= (a + 2)
== 6
>> a
== 6
>> a:= add a 2
== 8
>> a
== 8


however is this correct behaviour?

>> a: 4 ; this part is obviously okay
== 4
>> print a + 2
4
** Script error: + expected val1 of type number! not unset!
** near: print a + 2
>> a:= a + 2 ; reset 'a to :a THEN perform addition?
== 6
>> a
== 4
>> a:= add a 2
== 6
>> a
== 6

Let me know what you all think about this.

Ladislav, I do like your idea very much for using
"word::" as syntax for reset-word! types and it does
type much easier, so Iam considering it deeply, however
Iam sticking to my original idea of := for these
examples, I also think := is more visually distinctive
on page / screen than :: and has some historical
precedence from other languages, but I DO like the
ergonomic properties of your suggestion so it is still
up in the air as far as final syntax goes, but.....

I've been using a bit of PIKE recently and it's great
for prototyping C, C++ type programs in an interpretative
manner and it has properties which enable me to play
about with ideas for series! block! arrays vectors etc.
for PRIMO as well as infix operators.

What do you think of additional infix op! functions that
have destructive binding properties like reset-word!'s do.
Iam think of the C like operators that C, C++, Perl, Python
and Pike all share, here's what Iam proposing,

>> a: 4
== 4
>> a += 5
== 9
>> a
== 9
>> a:= 0
== 0
>> a
== 0
>> a:= (a + 1)
== 1
>> preset-add a 5
== 6
>> a
== 6
>> a += 5 ; Infix op! += equivalent to preset-add word value.
== 11
>> a
== 11
>> postset-add a 5
== 11
>> a
== 16
>> a =+ 5 ; Infix op! =+ equivalent to postset-add word value.
== 16
>> a
== 21
>> a:= unset ; same as to-unset a
== unset
>> a
** Script error: word a is an unset word, define word before use
** near: a
>> unset-word? a ; no need to quote word as func arg is a quoted 'value
== true

Viewed in this light, if these op!'s are acceptable then word:=
for reset-word! seems more in keeping with reset operators like
+= , -= , =+ etc.

Here's a full list of proposed op!'s with optional alternatives in
brackets to help ease people coming from other languages.

current op!'s

+ - * / ** (^) // (%) >= > = == < <= <> (!=) *see note below
and or xor

new op!'s

preset types perform action then return value

+= -= *= /= //= **= (^=) (%=)

postset types return existing word value then reset word
after peforming action.

=+ =- =* =/ =** =// (=^) (=%)

Interesting that the != for inequality is still lurking in REBOL
as anassignable infix op! value, see below.
>> !=: get to-word "<>"
>> 4 != 5
== true
>>

All the proposed new op!'s have their equivalent prefix functions.
+= or preset-add
=+ or postset-add
**= or preset-power
=** or postset-power

Might as well thrown in

Increment [value [word! number!]]
Decrement [value [word! number!]]

increment same as word += 1 or preset-add word 1
decrement same as word -= 1 or preset-subtract 1

note in these examples the :word must be a number!
for these funcs to work properly.

Anybody any comments?

cheers,

Mark Dickson




Fri Dec 14, 2001 12:35 pm

robbo1mark
Offline Offline
Send Email Send Email

Forward
Message #1011 of 1031 |
Expand Messages Author Sort by Date

PRIMO STRAW POLL / New Op!'s Question: Should paren!'s be necessary to enforce correct evaluation order in PRIMO when using infix operators? examples of...
Robbo1Mark@...
robbo1mark
Offline Send Email
Dec 14, 2001
12:35 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help