Random string samples & unicode

bearophile bearophileHUGS at lycos.com
Mon Sep 13 10:45:48 PDT 2010


Jonathan M Davis:

> Well, then in comparing python 3 with D, [...]

If you want to discuss about Python2/Python3 I think that the Python newsgroup is a better place. I know this sounds like a bit rough answer, but Python in the end is OT here, and most people here show some ignorance about Python matters.

-----------------------

Daniel Gibson:

> Can't you just use byte[] for that? If you're 100% sure your string
> only contains ASCII characters, you can just cast it to byte[], feed
> that into algorithms and cast it back to char[] afterwards, I guess.

ubyte[] sounds better :-) (Yes, I'd like D to use sbyte/ubyte names).

Yes, that's what I sometimes do. The usage of ubyte[] is the last possible solution I have suggested in my first post on this dual thread:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=117206

But that strategy needs casts, I don't like casts a lot, and I don't know how much SafeD supports casts (and you may want to use SafeD for the typically small script-like programs used for some intermediate processing of biological information). I think that generally it's better to use strategies that avoid casts. dsimcha's AsciiString may be able to reduce the need of casts.

-----------------------

Kagamin:

> Why they're chars but not numbers?

I presume it's mostly a matter of taste. There's no need to use chars here, but in scripting languages (especially Tcl) you sometimes use strings/chars even in situations where in C you want to use just numbers. Strings in Python are very handy to use, safe, compact in both memory and visual representation on screen.

-----------------------

Steven Schveighoffer:

> Fortunately, you can get the results you wish with the bracket notation:
> auto x = [s1, s2];

Right, thank you.

Bye,
bearophile


More information about the Digitalmars-d mailing list