Why Strings as Classes?

Chris R. Miller lordSaurontheGreat at gmail.com
Wed Aug 27 18:20:26 PDT 2008


superdan wrote:
> Chris R. Miller Wrote:
>> Furthermore, you're faulting linked lists as having a bad opIndex.  Why
>> not implement a cursor (Java LinkedList-like iterator) in the opIndex
>> function?  Thus you could retain the reference to the last indexed
>> location, and simply use that instead of the root node when calling
>> opIndex.  Granted that whenever the contents of the list are modified
>> that reference would have to be considered invalid (start from the root
>> node again), but it'd work with an O(1) efficiency for sequential
>> accesses from 0 to length.  True, it'll add another pointer to a node in
>> memory, as well as a integer representing the position of that node
>> reference.
> 
> you: "this scent will make skunk farts stink less."
> me: "let's kick the gorram skunk outta here!"

I would imagine that you'll have a hard time convincing others that
linked-lists are evil when you apparently have two broken shift keys.

>> Wrong.  It works.  That it's not precisely what the spec for sort
>> dictates (which is probably in error, since no spec can guarantee a
>> precise efficiency if it doesn't know the precise container type).
> 
> sure it can. in big oh.

Which is simply identifying the algorithm used by its efficiency.  If
you're not familiar with the types of algorithms, it tells you the
proximate efficiency of the algorithm used.  If you are familiar with
algorithms, then you can identify the type of algorithm used so you can
better leverage it to do what you want.

>>  You
>> are also misinterpreting the spec.  It is saying that it uses a specific
>> efficiency of algorithm, not that you can arbitrarily expect a certain
>> efficiency out of it regardless of how dumb you might be with the choice
>> of container you use.
> 
> in stl the spec says as i say. in d the spec is not precise. it should.

Yes, it probably should explicitly say that "sort uses the xxxxx
algorithm, which gives a proximate efficiency of O(n log n) when used
with optimal data structures."

You honestly cannot write a spec for generic programming and expect
uniform performance.

Trying to move back on topic, yes, I believe it is important that such a
degree of ambiguity be avoided with something so simple as string
handling.  So no strings-as-objects.  But writing a String class and
using that wherever possible is advantageous, especially because it does
not remove the ability of the language to support the simpler string
implementation.

>> A Ph.D from superdan... gee, I'd value that just above my MSDN
>> membership.  Remember: I value nothing less than my MSDN membership.
> 
> humor is a sign of intelligence. but let me explain it. i was referring to the spam emails advertising phds from non-accredited universities.

You get different spam than I do then.  I just get junk about cheap
Canadian pharmaceuticals and dead South African oil moguls who have left
large amounts of money in my name.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20080827/af5dd316/attachment.pgp>


More information about the Digitalmars-d mailing list