Re: Can Enums be integral types?

2022-04-19 Thread Manfred Nowak via Digitalmars-d-learn
On Sunday, 17 April 2022 at 18:25:32 UTC, Bastiaan Veelo wrote: The reason is in [17.1.5](https://dlang.org/spec/enum.html): “EnumBaseType types cannot be implicitly cast to an enum type.” Thy. That's the anchor in the specs preventing Enums to be integral types.

Can Enums be integral types?

2022-04-16 Thread Manfred Nowak via Digitalmars-d-learn
In the specs(17) about enums the word "integral" has no match. But because the default basetype is `int`, which is an integral type, enums might be integral types whenever their basetype is an integral type. On the other hand the specs(7.6.5.3) about types say | A bool value can be implicitly

Re: How to define property type to Array!struct?

2021-12-15 Thread Manfred Nowak via Digitalmars-d-learn
On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template having no parameters? Although the documentation declares such a template to be syntactically correct, not a

Re: Rules for Symbol Name Lookup seem contradictory

2020-06-22 Thread Manfred Nowak via Digitalmars-d-learn
On Monday, 22 June 2020 at 02:16:52 UTC, user1234 wrote: [...] Maybe that the spec is a bit vague as it doesn't mention that [...] A vague place in a spec is usually called "Dark Corner" and the functionality then marked as "Implementation defined". But this mark is missing here. And

Rules for Symbol Name Lookup seem contradictory

2020-06-21 Thread Manfred Nowak via Digitalmars-d-learn
https://dlang.org/spec/module.html#name_lookup contains under 4.3.4 only two sentences. While the first sentence explains, that the search ends "as soon as a matching symbol is found", the second sentence implies that the search may continue until it is sure, that no other symbol "with

Re: Is it possible to store different subclasses in one array?

2020-04-14 Thread Manfred Nowak via Digitalmars-d-learn
On Monday, 13 April 2020 at 05:54:52 UTC, evilrat wrote: if (auto weapon = cast(Weapon) gi) weapon.Attack(); Does the parlor (currently illegal in Dlang) if (Weapon w := gi) w.Attack(); look nicer or even (currently legal): if (Weapon w ._= gi)

Re: Docs 6.9.4: Implicit Conversion to bool

2020-03-09 Thread Manfred Nowak via Digitalmars-d-learn
On Monday, 9 March 2020 at 16:44:55 UTC, Steven Schveighoffer wrote: You're not the first person to ask. Accepted.

Docs 6.9.4: Implicit Conversion to bool

2020-03-09 Thread Manfred Nowak via Digitalmars-d-learn
Having a function `f' overloaded for argument types `bool' and `ulong', the specs guarantee, that for `f( 1uL)' the boolean overload of `f' is called. What is this good for?

Re: changing the output of `std.stdio.write'

2019-01-03 Thread Manfred Nowak via Digitalmars-d-learn
On Thursday, 3 January 2019 at 18:11:43 UTC, Paul Backus wrote: [...] functions [...] default to `%s`. thx. I should have rtfm instead of looking for an example. -manfred

changing the output of `std.stdio.write'

2019-01-03 Thread Manfred Nowak via Digitalmars-d-learn
According to this tutorial https://wiki.dlang.org/Defining_custom_print_format_specifiers it seems easy to change the format of the output for `std.stdio.writef'. But why is there no example for changing the output when there are no format specifiers? -manfred

Re: Distinguish recursive Templates

2015-05-22 Thread Manfred Nowak via Digitalmars-d-learn
Timon Gehr wrote: template getDepth(T){ static if(is(T==Set!S,S)) enum getDepth=1+getDepth!S; else enum getDepth=0; } Thx. Seems that I have to relearn a lot. -manfred

Re: Distinguish recursive Templates

2015-05-22 Thread Manfred Nowak via Digitalmars-d-learn
Matt Kline wrote: isn't making any use of the template argument T Correct. I do not know how to use `T' to determine the recursion depth of the template---and I want no further parameter. -manfred

Distinguish recursive Templates

2015-05-22 Thread Manfred Nowak via Digitalmars-d-learn
How can one determine the recursion depth for templated types? Example code: import std.stdio; class Set(T){ override string toString(){ return Set; } } void main(){ auto s0= new Set!uint; writeln( s0); // writes Set auto s1= new Set!(Set!uint); writeln( s1); // should write

Re: Dual conditions in D and Python

2015-05-21 Thread Manfred Nowak via Digitalmars-d-learn
Dennis Ritchie wrote: if (4 = 5 = 6): print (OK) - I would rather write: if( isSorted![4,5,6]) -manfred

Assertion failure without line

2015-05-20 Thread Manfred Nowak via Digitalmars-d-learn
core.exception.AssertError@stackext.d(0): Assertion failure how to handle this? -manfred

Re: Assertion failure without line

2015-05-20 Thread Manfred Nowak via Digitalmars-d-learn
Adam D. Ruppe wrote: assert inside a mixed in string. None praesent: private import star, stack; class StackExtended( T): Stack!T{ Star!T stacked; this(){ stacked= new Star!T;} auto opOpAssign( string op, T)( T node){ stacked+= node; return super+= node; } auto opUnary(

Re: Assertion failure without line

2015-05-20 Thread Manfred Nowak via Digitalmars-d-learn
Adam D. Ruppe wrote: My first gut idea Turns out: it is the usage of a variable - not newed, and - of a type declared in the file. -manfred

Re: UFCS

2015-05-16 Thread Manfred Nowak via Digitalmars-d-learn
Jonathan M Davis wrote: UFCS is only ever used with the . syntax The docs say so. Thx. -manfred

Deprecation

2015-05-15 Thread Manfred Nowak via Digitalmars-d-learn
Deprecation: super is not an lvalue 1) How to know when this will indeed be deprecated? 2) What does it mean, when `super++' is signalled as depracation, but `super+=' is not signalled? -manfred

Re: Deprecation

2015-05-15 Thread Manfred Nowak via Digitalmars-d-learn
Steven Schveighoffer wrote: That seems like a bug. https://issues.dlang.org/show_bug.cgi?id=14589 -manfred

UFCS

2015-05-15 Thread Manfred Nowak via Digitalmars-d-learn
The following gives: Error: 'a += b' is not a scalar, it is a C although UFCS should engage. -manfred class C{} int main(){ void opOpAssign( string op)( C a, C b){ } C a, b; a+= b; }

Error Compiling DMD

2015-05-11 Thread Manfred Nowak via Digitalmars-d-learn
std.process.ProcessException@std\process.d(560): Failed to spawn new process This is the error-message from the D-script from http://wiki.dlang.org/Building_DMD -manfred

Re: Bug or feature?

2015-05-10 Thread Manfred Nowak via Digitalmars-d-learn
Jack Applegame wrote: test(10); // error One can import the declaration by using an alias: class A { void test(int) {} } class B : A { alias test= super.test; void test() { super.test(1); // compiles test(10); // compiles } } -manfred

Re: Lambda functions in D

2015-05-09 Thread Manfred Nowak via Digitalmars-d-learn
Dennis Ritchie wrote: auto fact = function (int x) = x * { if (x) fact(x - 1); }; int fact (int x) { return x * ( x1 ? fact(x - 1): 1); }; -manfred

Re: opEquals optimized away?

2015-05-05 Thread Manfred Nowak via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 05:26:17 UTC, anonymous wrote: because `c is c` Thanks. One can see this documented in http://dlang.org/operatoroverloading.html#equals But 1: how can one override this behavior 2: what is the design reason for this Especially: how can one implement side effects

opEquals optimized away?

2015-05-04 Thread Manfred Nowak via Digitalmars-d-learn
class C{ override bool opEquals( Object o){ return true; } } unittest{ auto c= new C; assert( c == c); } `rdmd --main -unittest -cov' shows, that opEquals is not executed. Why? -manfred

Re: howto dispatch to derived classes?

2013-10-15 Thread Manfred Nowak
=?UTF-8?B?QWxpIMOHZWhyZWxp?= wrote: a virtual function like accept() can do the trick This would require changes in the whole class hierarchy. But because of The actual type of the object is implicitly stored in the vtbl of each type. and in addition, because the statement | writeln(

howto dispatch to derived classes?

2013-10-14 Thread Manfred Nowak
class C{} class C1:C{} // ... class Cn:C{} C getC(){ return new Cn;} // might be extern // and deliver some Ci void visit( C1 fp){} // ... void visit( Cn fp){} void main(){ visit( getC); // dispatch? } -manfred

Re: ieeeFlags are not getting set.

2013-09-29 Thread Manfred Nowak
Damien wrote: is not a D bug I cannot reproduce your problem. Giving 10^38 and 10 as parameters the lol is output correctly. -manfred

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: No it isn't according to dmd. dmd does not express this. according to p1.d(15): Error: [...] dmd cannot deduce that `Dptr!(T, U)' might be equal to `int delegate(int)' -manfred

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: How do I fix this? maybe it is currently not fixable because of restrictions in the deduction algorithm. Obviously the deduction works if the instantion of the template is replaced by a symbol by `alias T delegate( U) Dptr;' or similar. -manfred

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: Writing muddle!(int,int) [...] gives the same error message. Not entirely true: template muddle( T, U...){ alias T delegate( U) Dptr; auto muddle1( T, U...)( Dptr f) { return f; //or make another delegate in real code } alias muddle1!( T, U) muddle; }

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: is supposed to transform one delegate into another Then please declare the template parameters to be delegates: U muddle( T, U)( T f) { uint g( int fp){ return cast(uint)( 5* f( fp)); } auto gP= g; return gP; } unittest {

Re: Struct's alignment

2013-08-10 Thread Manfred Nowak
Temtaime wrote: What i'm doing wrong? Maybey nothing than thinking---that the adress is printed in the number of bits, whereas it is printed in the number of bytes. -manfred

Re: Is -1 7 ?

2013-08-09 Thread Manfred Nowak
michaelc37 wrote: WTF - -1 is greater than 7 From the docs: It is an error to have one operand be signed and the other unsigned for a , =, or = expression. -manfred

Re: Weird error occurance

2013-08-08 Thread Manfred Nowak
Josh wrote: I'm having a rather weird error when things that should have no effect are changed. Seems that inserting symbolic debug info is broken in such a way, that it touches ram out of its bounds---and the code for comparing the string covers that ram. Commenting out the code and the

Re: Insufficient Documentation?

2013-07-31 Thread Manfred Nowak
Jesse Phillips wrote: argument being passed was an object I see now, that you came to convert object because you know about the olution of the task given. Sooily the solution is unknown before hand! Of course my `class' printed out something that I didn't want to see. But I still do not see

Re: Insufficient Documentation?

2013-07-30 Thread Manfred Nowak
Jesse Phillips wrote: Writes its arguments in text format to the file. I'm not sure what results you are interest in when searching for arguments in text format. I expected a closer explanation for the broad explanation arguments in text format. If the explanation for `write' would be

Insufficient Documentation?

2013-07-29 Thread Manfred Nowak
http://dlang.org/phobos/std_stdio.html: void write(S...)(S args); Writes its arguments in text format to the file. 1) Feeding arguments in text format into the search-function for the whole site does not give a hint to `toString'. What am I missing? 2) to the file ... which file?

Re: Reverse Lexical Order

2013-07-16 Thread Manfred Nowak
On Tuesday, 16 July 2013 at 07:19:05 UTC, Jacob Carlborg wrote: The docs say: Any intervening finally clauses are executed, This does not solve: /begin{ code} markA: if( exp1) goto markB; if( exp2) goto markC; ... scope ... ... markB: if( exp3) goto markA; if( exp4) goto markC; ... scope

Re: Reverse Lexical Order

2013-07-15 Thread Manfred Nowak
Jonathan M Davis wrote: Under what circumstances would they not be the same thing? http://dlang.org/statement.html#GotoStatement At least the famous gots can make lexical ordering different to executional ordering. -manfred

Re: Reverse Lexical Order

2013-07-15 Thread Manfred Nowak
Jonathan M Davis wrote: gotos in such a context seem like a bit of a nightmare to me though. I did realize this nightmare. Therefore the assurance in the docs is probably true only in the absence within the scope of at least gotos to targets within the scope. -manfred

Re: template error instantiating

2012-11-18 Thread Manfred Nowak
Maxim Fomin wrote: How this is related I will be quiet on this, because non formal specifications tend to have ambiguities and I believe that the ambiguity I see escapes the intended scope; but I am not willing to check for this---and it is fruitless to explain such cases. -manfred

Re: template error instantiating

2012-11-17 Thread Manfred Nowak
Maxim Fomin wrote: related to the issue? ... I can see that the definition is ambiguous. And if the coder didnt't realize the ambiguousness as you do ... -manfred

Re: template error instantiating

2012-11-17 Thread Manfred Nowak
Timon Gehr wrote: The code given in the original post is valid D code. Yes, it is. But I see an ambiguity in the specs for this valid D code. -manfred

Re: Performance of hashes and associative arrays

2012-11-11 Thread Manfred Nowak
Jakse wrote: It would also be interesting to have ideas for the general case Yes, ideas might be interesting. :-) A root of good hashing is incorporated in algorithm2 of your posting: spread the values produced by the hash function uniformly over the interval size_t.min .. size_t.max.

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-11 Thread Manfred Nowak
Nick Sabalausky wrote: *but* head and tail are merely pointers to node Thank you. I do recognize now, that my flow of thought stopped at the same point at which the flow of control of the compiler stopped. -manfred

Re: Performance of hashes and associative arrays

2012-11-11 Thread Manfred Nowak
=?UTF-8?B?QWxpIMOHZWhyZWxp?= wrote: but the hash buckets are probably singly-linked lists They are unbalanced binary search trees, which indeed turn to singly-linked lists on sorted input. -manfred

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Timon Gehr wrote: In theory yes, but [...] What a pity. Because in the code given only the types Elem!0 and Elem!1 must be indeed initialized. The fact, that the specification of the template describes a family of types with an infinite number of members should not force the front end to

Re: Recursive data structure using template won't compile

2012-11-10 Thread Manfred Nowak
Rob T wrote: I want to create a simple recursive data structure as follows: struct R { int value; d_list!R Rlist; } I do not see any usage for the member `d_list!R Rlist'. Please explain. -manfred

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Nick Sabalausky wrote: I really don't see the relevance Please look at the definition of R: struct R { int value; d_list!R Rlist; } If no recursion was wanted the OP should have written: d_list!(R*) Rlist; In digitalmars.D.learn:40990 I already asked for an explanation. -manfred

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Rob T wrote: and the problem I'm experiencing is definitely a compiler bug I do not see that. Please work on my messages digitalmars.D.learn:40990 and digitalmars.D.learn:40991. -manfred

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Nick Sabalausky wrote: But the OP was never trying to do anything like that. See digitalmars.D.learn:40991 -manfred

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Timon Gehr wrote: But as this is an undecidable property in general I do not see, that the compiler has to solve the general case--- at least when compiling monolithic code and the executable is only allowed to use types which are initialized at compile time. Upon using several modules the

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-09 Thread Manfred Nowak
Nick Sabalausky wrote: So ok: s/There *IS NO RECURSION* here./There is no _IMPOSSIBLE_ recursion here./ That's one correection only. Several more are to come. Sorrily no one seems to have recognized this sentence in digitalmars.D.learn:40918: Because `R' can recurse infinitely over

Re: delegate bug?

2012-11-09 Thread Manfred Nowak
Jack Applegame wrote: dg.ptr = cast(void*)b; This changes the environment only. It does not change the function called on the``dg()'-request---and the function called does not depend on the environment. But including a dependence on the environment may not change the output, because the

Re: delegate bug?

2012-11-09 Thread Manfred Nowak
Jack Applegame wrote: Ok. Then how to implement in D this С++ std::function feature? http://liveworkspace.org/code/01aa058901529f65cb9a3cc4ba605248 That feature is among others defined here: http://en.cppreference.com/w/cpp/utility/functional/function As one might see it is a template,

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-09 Thread Manfred Nowak
Timon Gehr wrote: The example definitely exposes a bug in DMD. The D front end I am developing can already handle it. May I guess, that your front end is also able to handle this code: struct Elem( size_t myNumber) { Elem!( myNumber +1)* next; } void main(){ Elem!0 list; list.next= new

Re: Recursive data structure using template won't compile

2012-11-08 Thread Manfred Nowak
Rob T wrote: I want to be clear that I'm trying to define a recursive data structure [...] so correct me if there's a reasonable way to get this job done A recursive data structure needs a mooring ... and such a mooring is missing in the code given. -manfred

Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-08 Thread Manfred Nowak
Rob T wrote: | struct d_list( T ) | { |struct node |{ | T payload; | node* pred; | node* succ; |} |node* head; |node* tail; | } This doesn't loo like a list. It looks like the ancor of a list. Let me rewrite it and use D-parlor. | struct Ancor( T){ |

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-08 Thread Manfred Nowak
Manfred Nowak wrote: or `T' itself must take the lead. `T' was given as: | struct R | { | int value; | d_list!R Rlist; | } ... and using the given changes as well as D-parlor `T' becomes: | struct R { | int value; | Ancor!R list; | } Because `R' can recurse infinitely over

Re: Intended Security Hole?

2012-10-25 Thread Manfred Nowak
Justin Whear wrote: is used to create library shims One might be able to see: this is one of the roots of aspect programming. As a system programming language, D should be able to support this paradigm like aspectC++ shows for c++. Therefore: the answer to the subject is: yes. -manfred

Re: Intended Security Hole?

2012-10-25 Thread Manfred Nowak
Maxim Fomin wrote: b= d2; What is wrong here? The slight change in behavior might be unexpected and not intended for the owner of variable `Base b;'. What is the price ( i.e. coding time, execution time, execution space) the owner of that variable has to pay in the case that she/he want

Re: Intended Security Hole?

2012-10-25 Thread Manfred Nowak
Maxim Fomin wrote: Then disable behavior by marking class or function as a final. Do you really mean by this, that aspect programming is impossible in D? Or that marking `final' is enough? provide an example how you can do this. I was in fear and posted an approach. But I was not sure.

Re: Intended Security Hole?

2012-10-25 Thread Manfred Nowak
Maxim Fomin wrote: Why now you are complaining about this? Because this is the learn group and I did not realize, that the compiler does conform to the definition of overload resolution in function.html#function-inheritance, i.e. my expectation is defined as a bug. - manfred

Re: Intended Security Hole?

2012-10-24 Thread Manfred Nowak
Chris Cain wrote: So, no, the implementation wouldn't be changed during runtime since it must be provided when linking. Thats an expressed intent only. Reason: the linker does not know any thing about the language; the linker would be satisfied if there exists any function the linker can

Re: long compile time question

2012-10-24 Thread Manfred Nowak
Dan wrote: The following takes nearly three minutes to compile. ... and this returns immediately: struct B { const size_t SIZE = 1024*64; int[SIZE] x= void; // !!! } void main() { B[] barr; barr ~= B(); } --- - manfred

Re: floats default to NaN... why?

2012-04-14 Thread Manfred Nowak
F i L wrote: It sounds like circular reasoning. Several considerations pressed the design into the current form: 1) always changing output on unchanged input is hard to debug 2) GC needs to be saved from garbage, that looks like pointers 3) missed explicit initializations should not create

Re: floats default to NaN... why?

2012-04-14 Thread Manfred Nowak
F i L wrote: You can't force new D programmers to follow a 'guidline' By exposing a syntax error for every missed explicit initialization the current guideline would be changed into an insurmountable barrier, forcing every new D programmers to follow the 'guidline'. -manfred

Re: Name of files causes error. Why?

2012-04-12 Thread Manfred Nowak
Xan wrote: But it's a messy limitation. On the contrary: it requires work to implement limitations. Therefore limitations are implemented only to shield users from mess. Not having descovered any benefit of a limitation might point to insufficient empirical knowledge. -manfred

Re: float.nan is not itself ?

2012-02-14 Thread Manfred Nowak
Stewart Gordon wrote: If there were such a thing as bool.nan ... it would be called not-a-boolean. Of course it may make sense to compute something using such poisoned values. But if such values make sense, D is not prepared to use them, especially there is no if_then_else_otherwise

Re: Arrays - Inserting and moving data

2012-02-14 Thread Manfred Nowak
MattCodr wrote: I have a doubt about the best way to insert and move (not replace) some data on an array. I have the vision, that a mapping from a dense range of integers to some value type and wast (i.e. Theta( n)) changes of this mapping are a severe hint for a maldesign. -manfred

Re: toString multiple overrides

2012-02-11 Thread Manfred Nowak
Ellery Newcomer wrote: So this behavior is new, but is it sensical? It is a bug: If a mixin has a MixinIdentifier, it can be used to disambiguate [cited 11 Feb 2012 from http://www.d-programming-language.org/template-mixin.html ]

Re: dmd thrashes fedora

2012-02-11 Thread Manfred Nowak
Timon Gehr wrote: The error message says [...] recursive expansion I did not read that in the posts and on dmd 2.057/win32 only an out of memory was thrown. I'll attempt to analyse Good luck. -manfred

Re: How to reverse char[]?

2012-02-08 Thread Manfred Nowak
Jonathan M Davis wrote: thanks to how unicode works This does not mean, that the data structure representing a sequence of letters has to follow exactly the working you cited above. That data structure must only enable it efficiently. If a requirement for sequences of letters is, that a

For: [your code hear]

2012-02-07 Thread Manfred Nowak
Goal: show some skill of D for implementing mathematics. A definition: Let T1, T2, T3 be sets. A problem P of type ( T1, T2, T3) is interpretable as a function from the domain cartesian product of T1 and powerset of T2 to the codomain T3. Objective: Present code, that is usefull for all

Pitfall

2012-02-06 Thread Manfred Nowak
Today I got the nice message Error: undefined identifier missing from DMD2.057/win and was baffled for several minutes until I recognized the meaning. -manfred

Re: How far can CTFE go?

2012-02-04 Thread Manfred Nowak
H. S. Teoh wrote: If this was code generated by an external utility I wasn't argumenting for using external utilities, but against the argument, that separating code for separatable phases would obfuscate the code. for more than one _needed_ phase compile-time validation of generated code

Re: How far can CTFE go?

2012-02-03 Thread Manfred Nowak
Timon Gehr wrote: You probably haven't made extensive use of the feature. That is correct. - needed for a third compilation, needed for a fourth compilation, needed for a fifth compilation ... Provide an example please and I will change my opinion. - better syntax, can do complex things

Re: How far can CTFE go?

2012-02-02 Thread Manfred Nowak
H. S. Teoh wrote: the ideal situation would be that CTFE can replace writing an arbitrarily complex helper program Aebitrary complex helper programs may include viruses and other nice surprises. Walter does not want that adminstrators have to worry about a compilation step to torture the

Re: How far can CTFE go?

2012-02-02 Thread Manfred Nowak
H. S. Teoh wrote: I don't think that should be grounds to get rid of CTFE, though. In contrast to your remark, I do not see the benefits of reducing two compiling phases to one. For me CTFE ist nothing else than running the executables of a first compilation in order to get some values

Re: tdpl: function literals versus delegate lierals

2012-01-19 Thread Manfred Nowak
bearophile wrote: instead of SIMDs added Most delevopers at the same time like to turf their old errors and are keen to do something knew. -manfred

Re: Switch and break

2012-01-19 Thread Manfred Nowak
RenatoL wrote: why in D we are not obligated This depends on how the designer wants the coders to think about the semantics of a label. If a label _always_ is an _additional_ entry into an otherwise linear sequence of commands, then fall-through as standard is the consequence. If a label

Re: associative arrays

2012-01-10 Thread Manfred Nowak
dennis luehring wrote: so your FileDelete would not return an FileDoesNotExists-Error? Correct. would it not help to better understand big code if the remove would be renamed to remove_existing or to add something like this? Maybe. You possibly know about the `rm'-command of *nix-like

Re: associative arrays

2012-01-09 Thread Manfred Nowak
dennis luehring wrote: why is there an exception/error neeeded if missing? Exceptions or errors are not _needed_. Their existence stems from the modell under which the user of the operation _has_ to think about the operation, especially whether it is a:only the outcome of the operation or

Re: associative arrays

2012-01-08 Thread Manfred Nowak
simendsjo wrote: Wouldn't it make sense to return a pointer to the item being removed/null? According to the docs this is the intended behavior. -manfred

Re: associative arrays

2012-01-08 Thread Manfred Nowak
simendsjo wrote: it doesn't state return value Yes, I haven't read carefully enough. -manfred

Re: associative arrays

2012-01-08 Thread Manfred Nowak
Jonathan M Davis wrote: In this case, it's very much like dealing with C++ iterators A relevant part of Andrei's thread on associative arrays iteration: http://www.digitalmars.com/d/archives/digitalmars/D/associative_arrays_ iteration_is_finally_here_99576.html#N99614 -manfred

Re: associative arrays

2012-01-07 Thread Manfred Nowak
RenatoL wrote: Would not it be better if an exception was raised? No, because exceptions are guarenteed to be slow. if i write: writeln(arr1[xxx]); runtime expresses its disappointment... I would be disappointed too, if the commands for removing and for requesting something are sequenced in

Re: associative arrays

2012-01-07 Thread Manfred Nowak
Jonathan M Davis wrote: [...] This sort of explanation is missing in the docs. -manfred

Re: associative arrays

2012-01-07 Thread Manfred Nowak
Jonathan M Davis wrote: So, as far as I can tell, the current situation is more efficient There are some more arguments: 1) Different threads might want to `remove' the same key from the AA. I don't see a reason why only the first served thread should complete the operation without an error.

Re: Array of array

2012-01-02 Thread Manfred Nowak
RenatoL wrote: Error: new can only create structs, dynamic arrays or class objects, not int[][]'s There is an error in the error message: new can only create _static_ arrays. -manfred

Re: Array of array

2012-01-02 Thread Manfred Nowak
Jonathan M Davis wrote: new is used for creating _dynamic_ arrays, not static arrays. Correct, my fault. I meant something like statically initialized dynamic, because `new' currently needs an `uint' number to allocate some space for the elements of the outermost array. The posting shows,

Re: do-while loops

2011-12-28 Thread Manfred Nowak
bearophile wrote: void main() { do { int x = 5; } while (x != 5); // Error: undefined identifier x } Do you mean, that the similar while-loop should also be okay? | void main() { | while (x != 5) /* uses `x' out of _following_ scope */ { | int x = 5; | };