www.digitalmars.com         C & C++   DMDScript  

D - assoc-arrays; "not in" syntax

reply "Matthew Wilson" <matthew stlsoft.org> writes:
            if(file1 in map2)
            {
            }
            else
            {
                printf("  %.*s\n", file1);
            }

works ok, but

            if(file1 not in map2)
            {
                printf("  %.*s\n", file1);
            }

fails, as does

            if(not file1 in map2)
            {
                printf("  %.*s\n", file1);
            }

the only other one that works is

            if(!(file1 in map2))
            {
                printf("  %.*s\n", file1);
            }

I like the second form. Can we have that?

Matthew
Feb 05 2004
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
While it was 6/2/04 7:14 am throughout the UK, Matthew Wilson sprinkled 
little black dots on a white screen, and they fell thus:

<snip>
             if(file1 not in map2)
             {
                 printf("  %.*s\n", file1);
             }
 
 fails
<snip>
 I like the second form. Can we have that?
I guess that's really a matter if whether the syntactic sugar of such compound operators is worth implementing. If we're going to allow this, then we might as well allow such expressions as qwert not == yuiop asdfg not || hjkl etc. Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Feb 06 2004
next sibling parent reply Hauke Duden <H.NS.Duden gmx.net> writes:
Stewart Gordon wrote:
             if(file1 not in map2)
 I like the second form. Can we have that?
I guess that's really a matter if whether the syntactic sugar of such compound operators is worth implementing. If we're going to allow this, then we might as well allow such expressions as qwert not == yuiop asdfg not || hjkl
Hmmm. Somehow, this doesn't quite fit into the language. Why not using the "normal" way for C-based languages? I.e. if(a !in b) Hauke
Feb 06 2004
parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
"Hauke Duden" <H.NS.Duden gmx.net> wrote in message
news:c00eoq$1870$1 digitaldaemon.com...
 Stewart Gordon wrote:
             if(file1 not in map2)
 I like the second form. Can we have that?
I guess that's really a matter if whether the syntactic sugar of such compound operators is worth implementing. If we're going to allow this, then we might as well allow such expressions as qwert not == yuiop asdfg not || hjkl
Hmmm. Somehow, this doesn't quite fit into the language. Why not using the "normal" way for C-based languages? I.e. if(a !in b)
That would be fine.
Feb 06 2004
prev sibling parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message
news:c00bc1$12jt$1 digitaldaemon.com...
 While it was 6/2/04 7:14 am throughout the UK, Matthew Wilson sprinkled
 little black dots on a white screen, and they fell thus:

 <snip>
             if(file1 not in map2)
             {
                 printf("  %.*s\n", file1);
             }

 fails
<snip>
 I like the second form. Can we have that?
I guess that's really a matter if whether the syntactic sugar of such compound operators is worth implementing. If we're going to allow this, then we might as well allow such expressions as qwert not == yuiop asdfg not || hjkl
I don't see that that follows. What has == got to do with the "in" operator?
Feb 06 2004
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
While it was 6/2/04 8:59 pm throughout the UK, Matthew sprinkled little
black dots on a white screen, and they fell thus:
<snip>
 qwert not == yuiop
 asdfg not || hjkl
I don't see that that follows. What has == got to do with the "in" operator?
Comparatively little. But plenty in common: - both are binary operators - both evaluate to a boolean value Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Feb 09 2004