www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Random string samples & unicode

reply bearophile <bearophileHUGS lycos.com> writes:
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
Sep 13 2010
parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, September 13, 2010 10:45:48 bearophile wrote:
 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.

I wasn't really trying discuss python 2 vs 3 so much as point out that while you were lamenting the issues with porting python 2 code to D, it looks like the situation that you described for python 3 is essentially the same as for D, so it's a non-issue with regards to porting python 3 code. - Jonathan M Davis
Sep 13 2010