Jump to page: 1 2
Thread overview
opContains
Jan 21, 2004
Patrick Down
Jan 21, 2004
Vathix
Jan 21, 2004
C
Jan 21, 2004
Juan C
Jan 21, 2004
Matthew
Jan 21, 2004
C
Jan 21, 2004
The Lone Haranguer
Jan 21, 2004
C
Jan 21, 2004
Andy Friesen
Jan 21, 2004
Robert
Jan 22, 2004
Robert
Jan 21, 2004
Patrick Down
Jan 21, 2004
Stephan Wienczny
Jan 21, 2004
Patrick Down
Jan 22, 2004
Matthew
January 21, 2004
A an operator overload for 'in' would be nice.

class Foo
{
bool opContains(char[]) {}
}

Foo f;

if("bar" in f) { }


January 21, 2004
Patrick Down wrote:

> A an operator overload for 'in' would be nice.
> 
> class Foo
> {
> bool opContains(char[]) {}
> }
> 
> Foo f;
> 
> if("bar" in f) { }
>

Gets my vote. I was thinking of mentioning it several times. Although, I thought of naming it opIn; opContains is good too.
January 21, 2004
Very cool!

"Patrick Down" <Patrick_member@pathlink.com> wrote in message news:bukqnu$1sio$1@digitaldaemon.com...
>
> A an operator overload for 'in' would be nice.
>
> class Foo
> {
> bool opContains(char[]) {}
> }
>
> Foo f;
>
> if("bar" in f) { }
>
>


January 21, 2004
I guess if it's an operator "in" makes sense.
But if it's a method "contains" is better...
if ( f.Contains ( "bar" ) ) ...

And personally, I prefer methods rather than bogging a language down with operators. Especially when the operation is not likely to be used in a larger expression, as boolean expressions seldom are.

In article <buktne$217e$1@digitaldaemon.com>, C says...
>
>Very cool!
>
>"Patrick Down" <Patrick_member@pathlink.com> wrote in message news:bukqnu$1sio$1@digitaldaemon.com...
>>
>> A an operator overload for 'in' would be nice.
>>
>> class Foo
>> {
>> bool opContains(char[]) {}
>> }
>>
>> Foo f;
>>
>> if("bar" in f) { }
>>
>>
>
>


January 21, 2004
"Juan C" <Juan_member@pathlink.com> wrote in message news:bul8ct$2id6$1@digitaldaemon.com...
> I guess if it's an operator "in" makes sense.
> But if it's a method "contains" is better...
> if ( f.Contains ( "bar" ) ) ...
>
> And personally, I prefer methods rather than bogging a language down with operators. Especially when the operation is not likely to be used in a
larger
> expression, as boolean expressions seldom are.

In general I agree, but I think "in" will be widely used, especially if we can overload it.

I vote for opIn, btw. (Call it what it is)

> In article <buktne$217e$1@digitaldaemon.com>, C says...
> >
> >Very cool!
> >
> >"Patrick Down" <Patrick_member@pathlink.com> wrote in message news:bukqnu$1sio$1@digitaldaemon.com...
> >>
> >> A an operator overload for 'in' would be nice.
> >>
> >> class Foo
> >> {
> >> bool opContains(char[]) {}
> >> }
> >>
> >> Foo f;
> >>
> >> if("bar" in f) { }
> >>
> >>
> >
> >
>
>


January 21, 2004
I don't agree.
Indeed, it looks nice, but that's all.
I will be satisfied if there is 'member' method as Lisp and Prolog.

if(f.member("bar")) { }


"Patrick Down" <Patrick_member@pathlink.com> wrote in message news:bukqnu$1sio$1@digitaldaemon.com...
>
> A an operator overload for 'in' would be nice.
>
> class Foo
> {
> bool opContains(char[]) {}
> }
>
> Foo f;
>
> if("bar" in f) { }
>
>

January 21, 2004
The main reason for this is to be able to completely emulate the fuctionality of associative arrays.

In article <bukqnu$1sio$1@digitaldaemon.com>, Patrick Down says...
>
>
>A an operator overload for 'in' would be nice.
>
>class Foo
>{
>bool opContains(char[]) {}
>}
>
>Foo f;
>
>if("bar" in f) { }
>
>


January 21, 2004
I don't really like the double use of 'in' , I doubt this will take but what about renaming it to 'contains'.

char [ int ] hash;

if ( hash contains "element" ) { }

?

C
"Matthew" <matthew.hat@stlsoft.dot.org> wrote in message
news:bulf2p$2u6r$3@digitaldaemon.com...
>
> "Juan C" <Juan_member@pathlink.com> wrote in message news:bul8ct$2id6$1@digitaldaemon.com...
> > I guess if it's an operator "in" makes sense.
> > But if it's a method "contains" is better...
> > if ( f.Contains ( "bar" ) ) ...
> >
> > And personally, I prefer methods rather than bogging a language down
with
> > operators. Especially when the operation is not likely to be used in a
> larger
> > expression, as boolean expressions seldom are.
>
> In general I agree, but I think "in" will be widely used, especially if we can overload it.
>
> I vote for opIn, btw. (Call it what it is)
>
> > In article <buktne$217e$1@digitaldaemon.com>, C says...
> > >
> > >Very cool!
> > >
> > >"Patrick Down" <Patrick_member@pathlink.com> wrote in message news:bukqnu$1sio$1@digitaldaemon.com...
> > >>
> > >> A an operator overload for 'in' would be nice.
> > >>
> > >> class Foo
> > >> {
> > >> bool opContains(char[]) {}
> > >> }
> > >>
> > >> Foo f;
> > >>
> > >> if("bar" in f) { }
> > >>
> > >>
> > >
> > >
> >
> >
>
>


January 21, 2004
If it's not a mathematical operation it shouldn't be an operator.

In article <bumcqt$1ad8$1@digitaldaemon.com>, C says...
>
>I don't really like the double use of 'in' , I doubt this will take but what about renaming it to 'contains'.
>
>char [ int ] hash;
>
>if ( hash contains "element" ) { }
>
>?
>
>C
>"Matthew" <matthew.hat@stlsoft.dot.org> wrote in message
>news:bulf2p$2u6r$3@digitaldaemon.com...
>>
>> "Juan C" <Juan_member@pathlink.com> wrote in message news:bul8ct$2id6$1@digitaldaemon.com...
>> > I guess if it's an operator "in" makes sense.
>> > But if it's a method "contains" is better...
>> > if ( f.Contains ( "bar" ) ) ...
>> >
>> > And personally, I prefer methods rather than bogging a language down
>with
>> > operators. Especially when the operation is not likely to be used in a
>> larger
>> > expression, as boolean expressions seldom are.
>>
>> In general I agree, but I think "in" will be widely used, especially if we can overload it.
>>
>> I vote for opIn, btw. (Call it what it is)
>>
>> > In article <buktne$217e$1@digitaldaemon.com>, C says...
>> > >
>> > >Very cool!
>> > >
>> > >"Patrick Down" <Patrick_member@pathlink.com> wrote in message news:bukqnu$1sio$1@digitaldaemon.com...
>> > >>
>> > >> A an operator overload for 'in' would be nice.
>> > >>
>> > >> class Foo
>> > >> {
>> > >> bool opContains(char[]) {}
>> > >> }
>> > >>
>> > >> Foo f;
>> > >>
>> > >> if("bar" in f) { }
>> > >>
>> > >>
>> > >
>> > >
>> >
>> >
>>
>>
>
>


January 21, 2004
But we already have many operators that dont fall into that category.

int opCat (  int x)
int opIndex (  int x)
int opCall ( )
int opApply(int delegate(inout uint) dg)

How about , after this one , no more operators ;).

C


"The Lone Haranguer" <The_member@pathlink.com> wrote in message news:bumed2$1cqp$1@digitaldaemon.com...
> If it's not a mathematical operation it shouldn't be an operator.
>
> In article <bumcqt$1ad8$1@digitaldaemon.com>, C says...
> >
> >I don't really like the double use of 'in' , I doubt this will take but
what
> >about renaming it to 'contains'.
> >
> >char [ int ] hash;
> >
> >if ( hash contains "element" ) { }
> >
> >?
> >
> >C
> >"Matthew" <matthew.hat@stlsoft.dot.org> wrote in message
> >news:bulf2p$2u6r$3@digitaldaemon.com...
> >>
> >> "Juan C" <Juan_member@pathlink.com> wrote in message news:bul8ct$2id6$1@digitaldaemon.com...
> >> > I guess if it's an operator "in" makes sense.
> >> > But if it's a method "contains" is better...
> >> > if ( f.Contains ( "bar" ) ) ...
> >> >
> >> > And personally, I prefer methods rather than bogging a language down
> >with
> >> > operators. Especially when the operation is not likely to be used in
a
> >> larger
> >> > expression, as boolean expressions seldom are.
> >>
> >> In general I agree, but I think "in" will be widely used, especially if
we
> >> can overload it.
> >>
> >> I vote for opIn, btw. (Call it what it is)
> >>
> >> > In article <buktne$217e$1@digitaldaemon.com>, C says...
> >> > >
> >> > >Very cool!
> >> > >
> >> > >"Patrick Down" <Patrick_member@pathlink.com> wrote in message news:bukqnu$1sio$1@digitaldaemon.com...
> >> > >>
> >> > >> A an operator overload for 'in' would be nice.
> >> > >>
> >> > >> class Foo
> >> > >> {
> >> > >> bool opContains(char[]) {}
> >> > >> }
> >> > >>
> >> > >> Foo f;
> >> > >>
> >> > >> if("bar" in f) { }
> >> > >>
> >> > >>
> >> > >
> >> > >
> >> >
> >> >
> >>
> >>
> >
> >
>
>


« First   ‹ Prev
1 2