Some quick questions
Márcio Faustino
m.faustino at no.spam.gmail.com
Tue Aug 7 12:21:56 PDT 2007
Hi, I have some quick questions:
(1.) Why does version 2.0 of the compiler doesn't allow changing the
index of a foreach loop? For example:
;string format = "%s";
;
;foreach (i, c; format) {
; if (c != '%') {
; // ...
; continue;
; }
;
; switch (format[++i]) {
; case 's':
; // ...
; break;
; // ...
; }
;}
Instead of the (more tedious):
;string format = "%s";
;bool was_escape = false;
;
;foreach (i, c; format) {
; if (was_escape) {
; was_escape = false;
; continue;
; }
; if (c != '%') {
; // ...
; continue;
; }
;
; was_escape = true;
; switch (format[++i]) {
; case 's':
; // ...
; break;
; // ...
; }
;}
(2.) What's the rationale for opEquals returning an int, given that we
have a bool data type? (And it clearly returns a boolean value.)
(3.) Shouldn't the toHash method of the Object class return
"cast(hash_t) cast(void*) this" instead of "cast(uint) cast(void*)
this", since the hash_t type is defined differently for x86 and x64?
(4.) Shouldn't the equals method of the TypeInfo_i class use casts to
int's instead of uint's, since that TypeInfo class is for int's?
Thanks!
More information about the Digitalmars-d-learn
mailing list