June 08, 2004
Walter wrote:
> It's now possible to do assymmetrical operator overloads with commutative
> operators like +.
> 
> And it's now possible to create a << stream operator overloading in D. Not
> that I endorse such a use of operator overloading for non-arithmetic
> purposes, but it's now possible (without doing free operator functions or
> needing ADL, either!).
> 
> http://www.digitalmars.com/d/changelog.html

Default function arguments! Yay! Thanks Walter!

I can now delete about 1/3 of my functions :) :)

Hauke
June 08, 2004
Walter wrote:

> It's now possible to do assymmetrical operator overloads with commutative
> operators like +.
> 
> And it's now possible to create a << stream operator overloading in D. Not
> that I endorse such a use of operator overloading for non-arithmetic
> purposes, but it's now possible (without doing free operator functions or
> needing ADL, either!).

Kris's dsc.io project did that all along, so what's new?

And any particular reason for not inventing a whole new operator or two for stream I/O, as I briefly suggested?

http://www.digitalmars.com/drn-bin/wwwnews?D/25096


And have you actually seen my functions to fix bit array slicing?

http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/313

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.
June 08, 2004
Ivan Senji wrote:

<snip>
> Just a little question:
> # /The Expression within an array's brackets is now an AssignExpression (meaning that commas are no longer allowed). /
>  Could this mean that rectangular arrays are coming in some future? :)

Maybe.  It could also clear up what's FWIS a common coding error.

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.
June 08, 2004
In article <ca459b$pbu$1@digitaldaemon.com>, Stewart Gordon says...
>
>Walter wrote:
>
>> It's now possible to do assymmetrical operator overloads with commutative operators like +.
>> 
>> And it's now possible to create a << stream operator overloading in D. Not that I endorse such a use of operator overloading for non-arithmetic purposes, but it's now possible (without doing free operator functions or needing ADL, either!).
>
>Kris's dsc.io project did that all along, so what's new?
>
>And any particular reason for not inventing a whole new operator or two for stream I/O, as I briefly suggested?
>
>http://www.digitalmars.com/drn-bin/wwwnews?D/25096
>
>
>And have you actually seen my functions to fix bit array slicing?
>
>http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/313
>

Give him a break, he said before he can't cope with every thing that is offered here.

Ant


June 08, 2004
In article <ca3jmn$2pjm$1@digitaldaemon.com>, Walter says...
>
>Post it and let's have a look!
>
>

Walter: Here they be. :) I kept to a very simple "KISS" approach, and builded these functions upon the existing std.string functions. But if you'd like me to, I could make these functions independent of the other std.string functions so that these are in a stand alone raw "D" code format. I just didn't feel at the time that I should to follow a "Recreate the Wheel" approach, when the existing functions worked fine for what I needed.

Note - My indenting will disappear when I post this thru the Web...sorry about that! :(

/*******************************************************************
* Function      : int ifind( in char[], in char[], in int = 0 )
* Author        : David L. 'SpottedTiger' Davis
* Language      : DigitalMars "D" aka Mars v0.92
* Created Date  : 03.Jun.04
* Modified Date : 08.Jun.04 Removed the wrapper function and set
*                           the third parameter as a default of 0
* Requirements  : std.string
* Licence       : Same as those for the Phobos (Runtime Library)
*******************************************************************
*
* Note: Meant to be a case insensitive version of std.string.find
*       with an optional start looking from this "String Position" parameter.
*/
int ifind
(
in char[] sStr,
in char[] sSubStr,
in int    iStartPos = 0
)
{
char[] sTmpStr;
int    iRtnVal;

// If either of the string parameters are empty, return not found if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;

// If greater than to upper boundary return not found if ( iStartPos > sStr.length - 1 ) return -1;

// If less than to lower boundary return not found else if ( iStartPos < 0 ) return - 1;

sTmpStr = tolower( sStr[ iStartPos .. sStr.length ] );

if ( iStartPos == 0 )
return find( sTmpStr, tolower( sSubStr ) );
else
{
iRtnVal = find( sTmpStr, tolower( sSubStr ) );

return ( iRtnVal != -1 ) ? iStartPos + iRtnVal : iRtnVal;
}
} // end int ifind( char[],char[], int = 0 )


/*******************************************************************
* Function      : int irfind( in char[], in char[], in int = -1 )
* Author        : David L. 'SpottedTiger' Davis
* Language      : DigitalMars "D" aka Mars v0.92
* Created Date  : 03.Jun.04
* Modified Date : 08.Jun.04 Removed the wrapper function and set
*                           the third parameter as a default of -1
* Requirements  : std.string
* Licence       : Same as those for the Phobos (Runtime Library)
*******************************************************************
*
* Note: Meant to be a case insensitive version of std.string.rfind
*       with an optional start looking from this "String Position" parameter.
*/
int irfind
(
in char[] sStr,
in char[] sSubStr,
in int    iEndPos = -1
)
{
char[] sTmpStr;

// If either of the string parameters are empty, return not found if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;

// If iEndPos == -1 get the full length of the string
if ( iEndPos == -1 )
iEndPos = sStr.length - 1;

// If greater than to upper boundary return not found else if ( iEndPos > sStr.length - 1 ) return -1;

// If less than to lower boundary return not found else if ( iEndPos < 0 ) return - 1;

sTmpStr = tolower( sStr[ 0 .. iEndPos + 1 ] );

return rfind( sTmpStr, tolower( sSubStr ) );

} // end int irfind( char[],char[], int = -1 )

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
June 08, 2004
"Arcane Jill" <Arcane_member@pathlink.com> wrote in message news:ca3pa5$1r7$1@digitaldaemon.com...
>
> This is the best release of D I've seen so far. It's brilliant. Well done.

Thanks! I hope each one is better than the last <g>.


June 08, 2004
Thanks! I have some suggestions, though <g>. First, using toupper() allocates memory for the new string. While this works, it's better to avoid it if you can, i.e. just go through character by character and comparing that way. Second, I prefer to avoid a starting index; instead just slice the string to be searched. -Walter

"David L. Davis" <SpottedTiger@yahoo.com> wrote in message news:ca4lma$1m9r$1@digitaldaemon.com...
> In article <ca3jmn$2pjm$1@digitaldaemon.com>, Walter says...
> >
> >Post it and let's have a look!
> >
> >
>
> Walter: Here they be. :) I kept to a very simple "KISS" approach, and
builded
> these functions upon the existing std.string functions. But if you'd like
me to,
> I could make these functions independent of the other std.string functions
so
> that these are in a stand alone raw "D" code format. I just didn't feel at
the
> time that I should to follow a "Recreate the Wheel" approach, when the
existing
> functions worked fine for what I needed.
>
> Note - My indenting will disappear when I post this thru the Web...sorry
about
> that! :(
>
> /*******************************************************************
> * Function      : int ifind( in char[], in char[], in int = 0 )
> * Author        : David L. 'SpottedTiger' Davis
> * Language      : DigitalMars "D" aka Mars v0.92
> * Created Date  : 03.Jun.04
> * Modified Date : 08.Jun.04 Removed the wrapper function and set
> *                           the third parameter as a default of 0
> * Requirements  : std.string
> * Licence       : Same as those for the Phobos (Runtime Library)
> *******************************************************************
> *
> * Note: Meant to be a case insensitive version of std.string.find
> *       with an optional start looking from this "String Position"
parameter.
> */
> int ifind
> (
> in char[] sStr,
> in char[] sSubStr,
> in int    iStartPos = 0
> )
> {
> char[] sTmpStr;
> int    iRtnVal;
>
> // If either of the string parameters are empty, return not found if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;
>
> // If greater than to upper boundary return not found
> if ( iStartPos > sStr.length - 1 )
> return -1;
>
> // If less than to lower boundary return not found
> else if ( iStartPos < 0 )
> return - 1;
>
> sTmpStr = tolower( sStr[ iStartPos .. sStr.length ] );
>
> if ( iStartPos == 0 )
> return find( sTmpStr, tolower( sSubStr ) );
> else
> {
> iRtnVal = find( sTmpStr, tolower( sSubStr ) );
>
> return ( iRtnVal != -1 ) ? iStartPos + iRtnVal : iRtnVal;
> }
> } // end int ifind( char[],char[], int = 0 )
>
>
> /*******************************************************************
> * Function      : int irfind( in char[], in char[], in int = -1 )
> * Author        : David L. 'SpottedTiger' Davis
> * Language      : DigitalMars "D" aka Mars v0.92
> * Created Date  : 03.Jun.04
> * Modified Date : 08.Jun.04 Removed the wrapper function and set
> *                           the third parameter as a default of -1
> * Requirements  : std.string
> * Licence       : Same as those for the Phobos (Runtime Library)
> *******************************************************************
> *
> * Note: Meant to be a case insensitive version of std.string.rfind
> *       with an optional start looking from this "String Position"
parameter.
> */
> int irfind
> (
> in char[] sStr,
> in char[] sSubStr,
> in int    iEndPos = -1
> )
> {
> char[] sTmpStr;
>
> // If either of the string parameters are empty, return not found if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;
>
> // If iEndPos == -1 get the full length of the string
> if ( iEndPos == -1 )
> iEndPos = sStr.length - 1;
>
> // If greater than to upper boundary return not found
> else if ( iEndPos > sStr.length - 1 )
> return -1;
>
> // If less than to lower boundary return not found
> else if ( iEndPos < 0 )
> return - 1;
>
> sTmpStr = tolower( sStr[ 0 .. iEndPos + 1 ] );
>
> return rfind( sTmpStr, tolower( sSubStr ) );
>
> } // end int irfind( char[],char[], int = -1 )
>
> -------------------------------------------------------------------
> "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"


June 08, 2004
I want to at least make rectangular arrays possible with opIndex().
  "Ivan Senji" <ivan.senji@public.srce.hr> wrote in message news:ca3ps0$3am$3@digitaldaemon.com...
  WOW! Walter you are really making it harder and harder to complain about
  the language!!! :)

  Just a little question:
  a.. The Expression within an array's brackets is now an AssignExpression (meaning that commas are no longer allowed).

  Could this mean that rectangular arrays are coming in some future? :)

June 08, 2004
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:ca459b$pbu$1@digitaldaemon.com...
> Walter wrote:
>
> > It's now possible to do assymmetrical operator overloads with
commutative
> > operators like +.
> >
> > And it's now possible to create a << stream operator overloading in D.
Not
> > that I endorse such a use of operator overloading for non-arithmetic purposes, but it's now possible (without doing free operator functions
or
> > needing ADL, either!).
>
> Kris's dsc.io project did that all along, so what's new?
>
> And any particular reason for not inventing a whole new operator or two for stream I/O, as I briefly suggested?
>
> http://www.digitalmars.com/drn-bin/wwwnews?D/25096

I still think there's got to be a better way.

> And have you actually seen my functions to fix bit array slicing?
>
> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/313

It fixes it by making a copy. I'm not sure this is the right approach, since all the other array slicing points to the original.


June 08, 2004
In article <ca4ot4$1sek$2@digitaldaemon.com>, Walter says...
(in response to David L. Davis)
>
>I have some suggestions, though <g>. First, using toupper()
>allocates memory for the new string.

(I'm actually replying to David here, not Walter)
Another big problem with uppercasing the whole string is that it could be very
slow. Imagine if the strings you were comparing were gigabytes long. Now imagine
that the substring you were looking for could have been found right near the
start of the string. Converting the case of all those gigs would have been
unnecessary.

Sorry to be a downer, but I learned this the hard way a couple of years ago. I actually managed to implement the whole Unicode case comparison algorithm for real, including special casing and everything. Man, was it S-L-O-W. (It casefolded everything before the compare even started). Then I optimized it by making look at only as much of the strings as it needed to, and after that it whizzed by.

Jill