www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - More naming conventions

reply "Matthew Wilson" <admin.hat stlsoft.dot.org> writes:
[btw, sorry for the stream-of-consciousness blitzkrieg of posts, but DTL'll
do that to ya. :)]

Here's a thought:

Currently we cannot have overloads of member template functions. That's not
a massive hindrence, and I can live with it if providing it would be a
significant problem for compilation. However, it does leave us with a few
issues.

I'd like to suggest another naming convention, for collection members. Any
(constructive) thoughts on the following are welcome:

    Container
    {
        bool contains(value_type value)
        {
            . . .
        }
        template contains_if(F) { bool contains_if(F f)
        {
            . . .
        }}

        <result-set> sort()
        {
            . . .
        }
        template sort_with(F) { <result-set> sort_with(F f)
        {
            . . .
        }}


So, basically, we use the suffixes of "_if" and "_with". Is that digestible
to you good people?
Jul 16 2004
next sibling parent reply Matthias Becker <Matthias_member pathlink.com> writes:
Currently we cannot have overloads of member template functions. That's not
a massive hindrence, and I can live with it if providing it would be a
significant problem for compilation. However, it does leave us with a few
issues.

I'd like to suggest another naming convention, for collection members. Any
(constructive) thoughts on the following are welcome:

    Container
    {
        bool contains(value_type value)
        {
            . . .
        }
        template contains_if(F) { bool contains_if(F f)
        {
            . . .
        }}

        <result-set> sort()
        {
            . . .
        }
        template sort_with(F) { <result-set> sort_with(F f)
        {
            . . .
        }}


So, basically, we use the suffixes of "_if" and "_with". Is that digestible
to you good people?
hmm result = foo.sort_with (delegate bool (Bar x, Bar y) { return x > y; }); .. if (foo.contains_if (delegate bool (Bar x) { return x % 2 == 0; })) .. OK. I can live with that.
Jul 16 2004
parent Matthias Becker <Matthias_member pathlink.com> writes:
hmm

result = foo.sort_with (delegate bool (Bar x, Bar y) { return x > y; });
..
if (foo.contains_if (delegate bool (Bar x) { return x % 2 == 0; }))
..

OK. I can live with that.
Oops. It's result = foo.sort_with!(delegate bool (Bar x, Bar y)) (delegate bool (Bar x, Bar y) { return x > y; }); ..
if (foo.contains_if!(delegate bool (Bar x) ) (delegate bool (Bar x) { return x
% 2 == 0; }))
.. Well, naming is still ok, but this doesn't look too good, does it?
Jul 16 2004
prev sibling parent reply Jason Mills <jmills cs.mun.ca> writes:
Matthew Wilson wrote:
 So, basically, we use the suffixes of "_if" and "_with". Is that digestible
 to you good people?
I'm curious why you would use _if and _with, rather than the normal convention of separating words with capitals, like xxxIf, xxxWith? sort_with() contains_if() sortWith() containsIf() Jason
Jul 16 2004
parent reply "Matthew Wilson" <admin.hat stlsoft.dot.org> writes:
"Jason Mills" <jmills cs.mun.ca> wrote in message
news:cd8eas$5bc$1 digitaldaemon.com...
 Matthew Wilson wrote:
 So, basically, we use the suffixes of "_if" and "_with". Is that
digestible
 to you good people?
I'm curious why you would use _if and _with, rather than the normal convention of separating words with capitals, like xxxIf, xxxWith? sort_with() contains_if() sortWith() containsIf() Jason
A diet of too many languages. He he Sure, I mean sortWith and containsIf. :-)
Jul 16 2004
parent reply Brad Anderson <brad sankaty.dot.com> writes:
Matthew Wilson wrote:
 "Jason Mills" <jmills cs.mun.ca> wrote in message
 news:cd8eas$5bc$1 digitaldaemon.com...
 
Matthew Wilson wrote:

So, basically, we use the suffixes of "_if" and "_with". Is that
digestible
to you good people?
I'm curious why you would use _if and _with, rather than the normal convention of separating words with capitals, like xxxIf, xxxWith? sort_with() contains_if() sortWith() containsIf() Jason
A diet of too many languages. He he
Lisp? Ruby?
Jul 16 2004
parent "Matthew" <admin stlsoft.dot.dot.dot.dot.org> writes:
"Brad Anderson" <brad sankaty.dot.com> wrote in message
news:cd8kuh$7me$1 digitaldaemon.com...
 Matthew Wilson wrote:
 "Jason Mills" <jmills cs.mun.ca> wrote in message
 news:cd8eas$5bc$1 digitaldaemon.com...

Matthew Wilson wrote:

So, basically, we use the suffixes of "_if" and "_with". Is that
digestible
to you good people?
I'm curious why you would use _if and _with, rather than the normal convention of separating words with capitals, like xxxIf, xxxWith? sort_with() contains_if() sortWith() containsIf() Jason
A diet of too many languages. He he
Lisp? Ruby?
C++ first and foremost, but too much Ruby, Python, Perl of late as well. ;)
Jul 16 2004