REBOL 3.0

Comments on: Use ! and != in REBOL?

Carl Sassenrath, CTO
REBOL Technologies
2-May-2006 18:51 GMT

Article #0017
Main page || Index || Prior Article [0016] || Next Article [0018] || 35 Comments || Send feedback

There are a lot of little differences between REBOL and other languages. Some of these differences are important, and others are not.

For the most part REBOL differences were not based on a whim. For example, REBOL uses the block "[]" characters for a reason, and uses semicolon ";" comments for a similar reason: they are very easy-to-type unshifted keys on US keyboards (on non-US keyboards, well, sorry), and they print well (blocks look like blocks with []).

But, one difference that a few new users dislike is that REBOL's not-equals symbol is "<>". These chars were picked because < and > are used for comparisons, so putting them together for not-equal was logical.

However, the C language established the convention of "!=". This is a combination of not "!" and "=" (which does not actually mean equal in C, it means assignment, but we will ignore that little fact).

Currently in REBOL "!" or "!=" are not defined. But, we're trying to be more friendly in REBOL 3.0, even if just a bit. So, the question is, should we make these standard? (As a little history side-note, Python moved from <> to allowing != also.)

It's trivially easy to make this change, and if it makes a few hundred programmers happier, well, perhaps it's worth it. This isn't the first time we've considered this idea, but in REBOL 3.0 we're making a wide range changes, so it's a good idea to rediscuss a few of these small issues.

So, let's hear your comments on it.

35 Comments

Comments:

Brian Hawley
2-May-2006 16:36
I vote yes, because why not? ! and = are already word characters so it would be as simple as two assignments and adding one op word to DO. It would make things easier for people doing multi language programming, and if you don't like them, don't use them.
Carl Sassenrath
2-May-2006 17:07
In fact, in R3, it's just two assignments. :)
Brian Hawley
2-May-2006 17:21
User-defined operators? Yay!
Gregg Irwin
2-May-2006 18:47
Hmm, post got lost it seems...

Summed up:

I'm against it, unless there's a good reason that makes this change special, compared to all the other changes we could make to "be friendly".

Peter Wood
2-May-2006 18:47
:) Don't forget that is familiar to all Pascal programmers.
Peter Wood
2-May-2006 18:47
:) But not to Haloscan which gobbled the ""
Peter Wood
2-May-2006 18:47
:) One last try: <>
Paul Tretter
2-May-2006 21:32
:) I say we just keep the . I never had any other signficant experience in programming before REBOL and as soon as I saw the I understood essentially what it meant. So I can see the idea of "user-friendly" from this perspective.
Ed
2-May-2006 21:32
:) I vote in favor of enabling !=

Programmers are a fussy lot, and little annoyances add up.

One last (OT) note: if you add a regex engine to REBOL, you'll really get a lot of people to take a hard look at REBOL.

Just sayin'.

Jean-François
2-May-2006 23:44
:) I'm a beginner amateur programmer. I prefer the current less/greater for the following reasons:

- it immediately made sense - one less detail to learn - experienced programmers don't have to learn it because it makes sense for them too - beginners would have to learn this != even if they themselves don't use it because others would use it - when you back up and squint the less/greater is still visible therefore is a better visual cue at normal condition - less/greater is estheticaly more pleasing because of the symmetry

Brian Hawley
3-May-2006 0:00
Hey all, I don't think he's talking about dropping not and <>, just adding ! and != like how tail? and empty? refer to the same native.
Anton Rolls
3-May-2006 1:03
!= makes me happy. But, hmm, it looks like it depends on the programmer's background which he prefers. I was initially a Basic guy, then I discovered C and I thought it was cool. When I came to rebol I missed !=. Now, I can live without it. But you could use != in code which processes a lot of tags, thus being more distinguishable from all the tags and easier to read. To argue against myself; != adds no more functionality, whilst making the language slightly more complex, larger and perhaps more confusing to learn. Searching for datatypes in a script by just searching for "!" will now match != as well (which will waste a tiny bit of time as you have to distinguish it and process its meaning).

So, sadly, I think I have to go with self-restraint :-(

The other operators I miss more are ++, --, +=, *= etc.. Couldn't we find some way to do this nicely in rebol ?

Gregg Irwin
3-May-2006 2:00
I was waiting for the ++/-- request. :) I prefer INCR/DECR, especially if you want the C semantics where ++/-- can be pre or post ops; that's just bugs waiting to happen IME. Also, I think there's a much richer field of functionality when you think in terms of "incrementing". Maybe it's me, but I always said "plus plus" for ++, not increment, so why not just go with the word?

For +=, *=, etc., what about allowing a word! param for the basic math funcs?

Artem Hlushko
3-May-2006 2:48
"=" in "!=" in C does not relate to assingment. Look at the list of ">=", "
Artem Hlushko
3-May-2006 2:48
"=" in "!=" in C does not relate to assingment. Look at the list of "> =", "< =", "==", "!=". The pairs are used to construct comparison operators and they are consistent with opposition of "=" and "==".

I think "!=" will be inappropriate in Rebol.

Goldevil
3-May-2006 8:44
The less/greater is also used in other languages (I use often SQL and PL/SQL). In many other languages there are other syntaxes : Coldfusion use "neq" (not equal).

I think "!=" implemented in language is a bad idea.

A thing to try in rebol : using aliases to make the rebol syntax seems like another language. It's a bad idea because it leads to code that can be read easilly only by the author.

But it could be funny :

alias 'now "rightnow!"

Volker
3-May-2006 10:20
If you want to make c-coders happy, you need infix-priorities too. How about a dialect? if c[a += 4 != 5 + 6 * 7][..] Gabriele has a priority-dialect somewhere.
Volker
3-May-2006 10:22
if you want to make them really happy, make 'if paren-smart. if (a += 4 != 5 + 6 * 7)[..] with parens its c-like :)
maximo
3-May-2006 16:20
yippee!!!!

please add !=

I find != reads much better. And is consistent with >=

maximo
3-May-2006 16:26
yippee!!!!

please add !=

I find != reads much better. And is consistent with >= <=. it specifically reads "not equal". <> is interpreted as "different" but that's not how it actually reads.

and when you think about it, how can a word be larger or smaller than a string of text? as in:

a <> "text"

!= doesn't remove to rebol but it adds to those of us who do find <> is awkwards.

and != would make tags stick out more in this type of expression:

tag <> <home> tag != <home>

IMHO <> made sense far back when softwares only treated numbers, but in rebol that is hardly the case.

Sunanda
3-May-2006 19:49
If it helps new people and has no downsides, then why not?

Are you thinking of the full set?

!> -- not greater than !== -- strictly not equal to !and -- nand if !object? X -- if X is not an object!

etc

Some would be more useful than others :)

christophe
4-May-2006 4:05
"!=" is fine. But PLEASE make it a shortcut to the existing "", or it will broke a lot of things !
Gabriele
4-May-2006 7:10
:) Maximo, please note that you can use > and < on strings too; actually, on all series. They are just oredere alphabetically.
Jeff M
4-May-2006 13:50
:) I personally like it as . I program in C/C++ professionally, and very much like the fact that REBOL isn't trying to "be like everyone else". There's nothing inherently wrong with or !=, it's just a preference. But whatever the choice is, do *not* have both. Just pick one.
Bertrand
8-May-2006 5:54
:) I don't like "!=". Even it is commonly used in most programming language, it is not suited to inequality. On the contrary it tends to stress the equality : exclamation markmeans "be careful of the next thing". And the next thing is "=" !!!

I prefer "< >" more graphicly vivid, more intuitive ... perhaps more "Rebol" ?

Ammon Johnson
17-May-2006 13:19
:) I think adding "!" and "!=" is a good idea. So many other languages use this that it seems to be the first thing a programmer tries when first playing with REBOL. Friendly is good. On that note... We really need ++/-- operators as well.
Richard
23-May-2006 6:08
Yes, I think != would be a good addition, alongside the existing "" not-equals in Rebol.
Richard
23-May-2006 6:10
[This comments editor is crappy - Preview eats angle brackets...] That was supposed to say "<>"
Ladislav
25-Aug-2006 3:17:04
I prefer to have one standard, not two in this case. The way it is now makes good sense to me.
Ladislav
25-Aug-2006 3:25:51
Regarding the ++ operator - the biggest problem I see is how to discern the "prefix" and "postfix" version. Something like

!++: func [word [word!]] [set word 1 + get word]

++!: func [word [word!] /local result] [result: get word set word result + 1 result] ?

Scot
25-Sep-2006 18:54:39
<> gets my vote. I generally like all the languages that use != less than the languages that use <>. I always try <> before I try !=. Besides it's really easy to type. Why trade opposite ends of the keyboard for two keys right next to eachother?
Hegemon
26-Nov-2006 18:05:38
I vote for !=

<> reads "lesser or greater"
!= reads "not equal"

The two are not the same from relational point of view. One might want to compare pairs: 2x3 and 3x2. It's obvious none of them is greater nor lesser than the other. But i'm pretty sure they're not equal. So it'd better to write 2x3 (not equal) 3x2, which implies != than 2x3 (lesser or greater) 3x2.

So since one might want to compare more complex objects than just numbers and strings REBOL should use !=

oyster
27-Nov-2006 23:09:41
I think it is ok to add != while keeping <>
The thing I only dislike is the assignment :, I have to press 2 keys at the same time. No matter in C, BASIC or python, = is used foe assignment. Well, I just complained and I think there is no way to switch : to =
Maxim Olivier-Adlhoch
29-Nov-2006 21:53:42
you'll have tough time getting support even if it where possible ;-)

Its one the most source readability enabling features of REBOL.

It reads just like in plain english.

the two keys you talk about sit so close to each other they are virtually typed as one.

Johan Aires Rasten
24-Oct-2007 10:02:53
I think != makes sense only when ! means "logical not" in a language.

And you can't say "let those who like != use it and the rest won't have to care", since people upload code and examples. I mean seriously, would anyone want to work with a script or program where both != and the classic Rebol not-equal?

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0017


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 24-May-2017 - Edit - Copyright REBOL Technologies - REBOL.net