Jump to page: 1 26  
Page
Thread overview
English binary logic operators
Nov 07, 2006
David Qualls
Nov 07, 2006
Bill Baxter
Nov 08, 2006
Ary Manzana
Nov 23, 2006
antonio
Nov 23, 2006
nobody_
Nov 23, 2006
Daniel Giddings
Nov 23, 2006
antonio
Nov 24, 2006
Carlos Santander
Nov 24, 2006
Georg Wrede
Nov 24, 2006
Ary Manzana
Nov 24, 2006
Carlos Santander
Nov 24, 2006
Don Clugston
Nov 26, 2006
nobody_
Nov 26, 2006
nobody_
Nov 26, 2006
antonio
Nov 24, 2006
Bruno Medeiros
Nov 25, 2006
antonio
Nov 25, 2006
Bill Baxter
Nov 28, 2006
Bruno Medeiros
Nov 29, 2006
Bill Baxter
Nov 29, 2006
John Reimer
Nov 26, 2006
nobody_
Nov 24, 2006
Don Clugston
Nov 27, 2006
Craig Black
Nov 27, 2006
Lars Ivar Igesund
Nov 28, 2006
David Qualls
Nov 28, 2006
Thomas Kuehne
Nov 28, 2006
Daniel Keep
Nov 28, 2006
Sean Kelly
Nov 28, 2006
Bill Baxter
Nov 29, 2006
Daniel Keep
Nov 30, 2006
Don Clugston
Nov 08, 2006
Bill Baxter
Nov 08, 2006
Sean Kelly
Nov 14, 2006
Bruno Medeiros
Nov 14, 2006
Sean Kelly
Nov 08, 2006
BCS
Nov 08, 2006
Ary Manzana
Nov 08, 2006
Bill Baxter
Nov 08, 2006
Hasan Aljudy
Nov 10, 2006
Daniel Keep
Nov 10, 2006
Max Bolingbroke
Nov 10, 2006
Bill Baxter
Nov 10, 2006
Bill Baxter
Nov 10, 2006
Hasan Aljudy
Nov 11, 2006
Bill Baxter
Nov 12, 2006
Georg Wrede
Nov 13, 2006
Daniel Keep
Nov 13, 2006
Bill Baxter
Nov 23, 2006
antonio
Nov 24, 2006
Samuel MV
Nov 24, 2006
Frits van Bommel
November 07, 2006
I just compiled my first D function (adapted from C), and had to replace all my 'and' 'or' and 'not's with the arcane &&, ||, and ! from prehistoric C to get it to compile.

iso646.h has been a part of C for several years.  Perl, C++ and possibly other languages have all adopted 'and', 'or', and 'not' as part of their grammar.

I write software that will be maintained by non-programmers
(mathematicians, who would prefer that I use Fortran).  Lots of
funny symbols in source code (like && || !) make it difficult to
read for the non-immersed (ah, who am I kidding, I even have
trouble reading it now and then).

Is there any future to D incluing the logical operators in English, as opposed to &!|%'ish?  (I didn't mention it, but 'mod' might also be a good (easy for non-programmers to understand) substitute for '%'.)

David
November 07, 2006
David Qualls wrote:
> I just compiled my first D function (adapted from C), and had to
> replace all my 'and' 'or' and 'not's with the arcane &&, ||, and !
> from prehistoric C to get it to compile.
> 
> iso646.h has been a part of C for several years.  Perl, C++ and
> possibly other languages have all adopted 'and', 'or', and 'not'
> as part of their grammar.
> 
> I write software that will be maintained by non-programmers
> (mathematicians, who would prefer that I use Fortran).  Lots of
> funny symbols in source code (like && || !) make it difficult to
> read for the non-immersed (ah, who am I kidding, I even have
> trouble reading it now and then).
> 
> Is there any future to D incluing the logical operators in
> English, as opposed to &!|%'ish?  (I didn't mention it, but 'mod'
> might also be a good (easy for non-programmers to understand)
> substitute for '%'.)
> 
> David

+1

After 20 years of C/C++ my use of && and || was pretty instinctual, but after just a few months of working with Python on the side I found I started typing 'and' and 'or' without thinking about it.  It makes complicated expressions more readable and would fit in great with D's more "modern" look.

As noted before, I'm also in favor of allowing 'in' to replace ';' in foreach statements.

--bb
November 08, 2006
Bill Baxter escribió:
> David Qualls wrote:
>> I just compiled my first D function (adapted from C), and had to
>> replace all my 'and' 'or' and 'not's with the arcane &&, ||, and !
>> from prehistoric C to get it to compile.
>>
>> iso646.h has been a part of C for several years.  Perl, C++ and
>> possibly other languages have all adopted 'and', 'or', and 'not'
>> as part of their grammar.
>>
>> I write software that will be maintained by non-programmers
>> (mathematicians, who would prefer that I use Fortran).  Lots of
>> funny symbols in source code (like && || !) make it difficult to
>> read for the non-immersed (ah, who am I kidding, I even have
>> trouble reading it now and then).
>>
>> Is there any future to D incluing the logical operators in
>> English, as opposed to &!|%'ish?  (I didn't mention it, but 'mod'
>> might also be a good (easy for non-programmers to understand)
>> substitute for '%'.)
>>
>> David
> 
> +1
> 
> After 20 years of C/C++ my use of && and || was pretty instinctual, but after just a few months of working with Python on the side I found I started typing 'and' and 'or' without thinking about it.  It makes complicated expressions more readable and would fit in great with D's more "modern" look.
> 
> As noted before, I'm also in favor of allowing 'in' to replace ';' in foreach statements.
> 
> --bb

I guess the main reason to stick with symbols is some compatibility with C/C++ source code.

Anyway, I also like the idea of words instead of symbols. You benefit from readability and it's also much more simpler to type (i.e. you don't you shift or look in a new keyboar for them).
November 08, 2006
Bill Baxter wrote:
> David Qualls wrote:

> After 20 years of C/C++ my use of && and || was pretty instinctual, but after just a few months of working with Python on the side I found I started typing 'and' and 'or' without thinking about it.  

I think my meaning wasn't so clear so let me rephrase.

It took no time to get used to 'and/or' when learning python.  I don't recall ever mistakenly using '&&' in my first few python attempts.  But what happened after a few months (and continues to today) is that I sometimes type 'and/or' in *C++* code (and now *D* too) when I mean &&/||.

I think it's just because in my head I'm *thinking* 'if this and that' as I type.  My brain recognizes 'and' as a legal keyword from somewhere and so my fingers type it.

Unfortunately, if && and || are to be eliminated wholesale, the benefit will be seen as too small to be worth the pain of fixing all old code. Furthermore Walter believes that C/C++ syntax must be good enough or it wouldn't have survived so long (or something like that).  And he believes that D should look and behave like C/C++ as much as possible to ease the transition for C/C++ refugees (hence the decision to not fix how switch works).  He also believes that symbols (!@#$%^&*) should be used wherever possible instead of new keywords (hence we have ':' showing up everywhere for all kinds of different purposes, and "static" with even more meanings than in C++).

It could be possible to add 'and' and 'or' as _synonyms_, but that smacks as too many ways to do the same thing, and adds two keywords for something for which there is already another way to do it.  It doesn't let you do or express anything you couldn't before.

So in short, it's pretty hopeless.  But I agree it would make the code more readable and make overall for a more aesthetically pleasing language.  Maybe it could be considered for a backwards-incompatible D 2.0.  Maybe D 2.0 will have a way to redefine or alias keywords so you could just "import std.english_keywords" to get that functionality.  The problem with that will be that Walter really likes for D to be easy to parse, and part of that is being able to recognize tokens as keywords immediately without any special complicated logic.

But I'm with you.  It would be nice to see in D 2.0.

One thing the NumPy folks did as they made lots of changes prior to 1.0 was to keep a 'convertCode' script up to date with each change.  For most cases just running 'convertCode' on your source files is enough to get you pretty close to compatible with the latest code.

--bb
November 08, 2006
David Qualls wrote:
> I just compiled my first D function (adapted from C), and had to
> replace all my 'and' 'or' and 'not's with the arcane &&, ||, and !
> from prehistoric C to get it to compile.
> 
> iso646.h has been a part of C for several years.  Perl, C++ and
> possibly other languages have all adopted 'and', 'or', and 'not'
> as part of their grammar.
> 
> I write software that will be maintained by non-programmers
> (mathematicians, who would prefer that I use Fortran).  Lots of
> funny symbols in source code (like && || !) make it difficult to
> read for the non-immersed (ah, who am I kidding, I even have
> trouble reading it now and then).
> 
> Is there any future to D incluing the logical operators in
> English, as opposed to &!|%'ish?  (I didn't mention it, but 'mod'
> might also be a good (easy for non-programmers to understand)
> substitute for '%'.)
> 
> David

Interesting, I have never heard about iso646.h before. I have never seen any code that used it either.

I only speak for my self, but I wouldn't use it and would find it harder to use. I like the &!|% version because it doesn't look like an identifier.
November 08, 2006
> I only speak for my self, but I wouldn't use it and would find it harder to use. I like the &!|% version because it doesn't look like an identifier.

"and" dosen't look like an identifier in my editor: it's blue instead of black :-P
November 08, 2006
BCS wrote:
> David Qualls wrote:
>> I just compiled my first D function (adapted from C), and had to
>> replace all my 'and' 'or' and 'not's with the arcane &&, ||, and !
>> from prehistoric C to get it to compile.
>>
>> iso646.h has been a part of C for several years.  Perl, C++ and
>> possibly other languages have all adopted 'and', 'or', and 'not'
>> as part of their grammar.
>>
>> I write software that will be maintained by non-programmers
>> (mathematicians, who would prefer that I use Fortran).  Lots of
>> funny symbols in source code (like && || !) make it difficult to
>> read for the non-immersed (ah, who am I kidding, I even have
>> trouble reading it now and then).
>>
>> Is there any future to D incluing the logical operators in
>> English, as opposed to &!|%'ish?  (I didn't mention it, but 'mod'
>> might also be a good (easy for non-programmers to understand)
>> substitute for '%'.)
>>
>> David
> 
> Interesting, I have never heard about iso646.h before. I have never seen any code that used it either.

I'd never heard of it either.  But I love the description on this page:
http://www.frech.ch/man/man0p/iso646.h.0p.html

  APPLICATION USAGE
      none.

  RATIONALE
      none.


So it's of no use and there's no reason for it.  Great!

> I only speak for my self, but I wouldn't use it and would find it harder to use. I like the &!|% version because it doesn't look like an identifier.

In &&'s favor it also lets you really cram things together :-)

     if(a&&b&&c)

has to become

     if(a and b and c)

with words.  But that's not necessarily a good thing.  Which of the above would you rather be staring at at 3am at the end of a long night coding?

--bb
November 08, 2006
Bill Baxter wrote:
> Bill Baxter wrote:
>> David Qualls wrote:
> 
>> After 20 years of C/C++ my use of && and || was pretty instinctual, but after just a few months of working with Python on the side I found I started typing 'and' and 'or' without thinking about it.  
> 
> I think my meaning wasn't so clear so let me rephrase.
> 
> It took no time to get used to 'and/or' when learning python.  I don't recall ever mistakenly using '&&' in my first few python attempts.  But what happened after a few months (and continues to today) is that I sometimes type 'and/or' in *C++* code (and now *D* too) when I mean &&/||.
> 
> I think it's just because in my head I'm *thinking* 'if this and that' as I type.  My brain recognizes 'and' as a legal keyword from somewhere and so my fingers type it.
> 
> Unfortunately, if && and || are to be eliminated wholesale, the benefit will be seen as too small to be worth the pain of fixing all old code. Furthermore Walter believes that C/C++ syntax must be good enough or it wouldn't have survived so long (or something like that).  And he believes that D should look and behave like C/C++ as much as possible to ease the transition for C/C++ refugees (hence the decision to not fix how switch works).  He also believes that symbols (!@#$%^&*) should be used wherever possible instead of new keywords (hence we have ':' showing up everywhere for all kinds of different purposes, and "static" with even more meanings than in C++).
> 
> It could be possible to add 'and' and 'or' as _synonyms_, but that smacks as too many ways to do the same thing, and adds two keywords for something for which there is already another way to do it.  It doesn't let you do or express anything you couldn't before.

For what it's worth, 'and' and 'or' as synonyms for '&&' and '||' already exists in C/C++.  Trigraphs are a largely unknown feature that many appear to dislike, but I have read a reasonable argument that they are useful for teaching new programmers.  Personally, I think that learning the meaning of new symbols is part of learning any language, so what's important is really that these symbols be easily recognizable and clearly meaningful.  Once you've learned that '&&' represents a logical 'and' operation, are you liable to forget that or mistake it for something else?  Also, binary 'and' (ie. '&') may want a descriptive term as well, if we're adding support for the logical operators.  And I think that's when things begin to get confusing with the English terms.


Sean
November 08, 2006

Bill Baxter wrote:
> BCS wrote:
>> David Qualls wrote:
>>> I just compiled my first D function (adapted from C), and had to
>>> replace all my 'and' 'or' and 'not's with the arcane &&, ||, and !
>>> from prehistoric C to get it to compile.
>>>
>>> iso646.h has been a part of C for several years.  Perl, C++ and
>>> possibly other languages have all adopted 'and', 'or', and 'not'
>>> as part of their grammar.
>>>
>>> I write software that will be maintained by non-programmers
>>> (mathematicians, who would prefer that I use Fortran).  Lots of
>>> funny symbols in source code (like && || !) make it difficult to
>>> read for the non-immersed (ah, who am I kidding, I even have
>>> trouble reading it now and then).

ummmm .. mathematicians use more complicated symbols and notations than programmers.

>>>
>>> Is there any future to D incluing the logical operators in
>>> English, as opposed to &!|%'ish?  (I didn't mention it, but 'mod'
>>> might also be a good (easy for non-programmers to understand)
>>> substitute for '%'.)
>>>
>>> David
>>
>> Interesting, I have never heard about iso646.h before. I have never seen any code that used it either.
> 
> I'd never heard of it either.  But I love the description on this page:
> http://www.frech.ch/man/man0p/iso646.h.0p.html
> 
>   APPLICATION USAGE
>       none.
> 
>   RATIONALE
>       none.
> 
> 
> So it's of no use and there's no reason for it.  Great!
> 
>> I only speak for my self, but I wouldn't use it and would find it harder to use. I like the &!|% version because it doesn't look like an identifier.
> 
> In &&'s favor it also lets you really cram things together :-)
> 
>      if(a&&b&&c)
> 
> has to become
> 
>      if(a and b and c)
> 
> with words.  But that's not necessarily a good thing.  Which of the above would you rather be staring at at 3am at the end of a long night coding?
> 
> --bb

I actually like symbols in code because they stand out right away.
I always prefer {braces} to begin/end.
At the same time, I hate too many symbols too close to each other.
November 10, 2006

Hasan Aljudy wrote:
> ...
> ummmm .. mathematicians use more complicated symbols and notations than
> programmers.

It's funny; but the early programming languages were designed by mathematicians.  Trust me, if they'd been able to use ∧ for and, and ∨ for or, they would have :)  On a few systems, they actually *did*.  I think programmers use "simpler" notation simply because we're limited to what we can bang out on a keyboard, and mathematicians aren't.

(In fact, mathematicians seem to *love* inventing new symbols: the guy who invented lambda calculus originally wanted to introduce a new symbol.  But when it was sent off to be published, the typesetter mistook his new symbol for a lambda (λ), and it kinda stuck :P)

Incidentally, I think the symbols used in mathematics are better if they're available since they're pretty unique, and stand out even better.  An interesting thing to try is writing up some CWEB code: it converts all the &&s and ||s to ∧s and ∨s in the TeX documentation :3

> ...
> I actually like symbols in code because they stand out right away.
> I always prefer {braces} to begin/end.
> At the same time, I hate too many symbols too close to each other.

I prefer using names if the names are short and meaningful.  It makes code that little less cryptic.  As long as you don't end up with insane symbols like #!@$? actually *meaning* something, it all works either way.

Similarly, one of the reasons I hate Java is because everyIdentifierIsACompleteAndGrammaticallyCorrectSentence .justBecauseTheyCan(andItMakesWritingLongExpressionsInJava .aTotalPainInTheArse)

Ah well, each to their own, I suppose.

	-- Daniel

-- 
Unlike Knuth, I have neither proven or tried the above; it may not even make sense.

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/
« First   ‹ Prev
1 2 3 4 5 6