Re: pseudo-specs for a String class: tokenization

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Mon, 08 Sep 2008 09:11:03 -0600

On Mon, 2008-09-08 at 15:49 +0200, Kinkie wrote:

> But I'd leave the operator =
>
> KBuf foo="bar";
> is quite convenient IMO.

It sure is, and I have no objections at this point.

In many cases, the assignment would look like

  String foo = some expression returning char*;

though and the developer will miss cases where a String is converted to
char* and then converted back to [a new] String. In other words, the
char* assignment operator helps to miss escapes from the carefully
designed String and Buffer "garden" even if it only provides a backdoor
into that garden.

Since statements like the example above should be rarely executed (for
performance reasons), I think making them inconvenient may be a good
thing:

  String foo = String::Allocate("bar"); // XXX: expensive!
or
  String foo = String::Create("bar"); // TODO: make a static const

Cheers,

Alex.
Received on Mon Sep 08 2008 - 15:11:45 MDT

This archive was generated by hypermail 2.2.0 : Thu Sep 11 2008 - 12:00:11 MDT