Re: setjmp / longjmp

2015-06-09 Thread Stewart Gordon via Digitalmars-d-learn
On 27/04/2015 10:41, ketmar wrote: snip i believe this has something to do with exception frames. but it needs further investigation. What is an exception frame, exactly? Moreover, are these frames applicable even in sections of code where no throwing or catching of exceptions takes place?

Re: setjmp / longjmp

2015-04-26 Thread Stewart Gordon via Digitalmars-d-learn
On 26/04/2015 06:56, ketmar wrote: snip you shouldn't use setjmp/longjmp in D. use exceptions instead. something like this: snip True in the general case. Still, there must be some reason that trying it in D causes an AV (even if I disable the GC). I remain curious about what that reason

Re: multidimensional array

2014-09-28 Thread Stewart Gordon via Digitalmars-d-learn
On 28/09/2014 08:48, ketmar via Digitalmars-d-learn wrote: On Sun, 28 Sep 2014 04:24:19 + Joel via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: struct Spot { bool dot; } spots = new Spot[][](800,600); btw, does anybody know why i can do `new ubyte[256];` but not `new

Re: Limit number of compiler error messages

2012-05-27 Thread Stewart Gordon
On 22/05/2012 18:36, cal wrote: snip my build command 21 | head -n number of lines you want to see Where my build command is your dmd/rdmd/build script command. There's probably something similar you could use on Windows, I don't really know though. By something similar do you mean a way of

Re: ProjectEuler problem 35

2012-05-20 Thread Stewart Gordon
On 19/05/2012 16:13, maarten van damme wrote: A huge optimization could be made by storing and int array of already found primes and test all primes smaller then half the to-test number. this will speed up a lot. Do you mean build an array of already-found primes and use them to test new

Re: ProjectEuler problem 35

2012-05-19 Thread Stewart Gordon
On 16/05/2012 10:46, Dmitry Olshansky wrote: snip Don't ever do that. I mean allocating memory in tight cycle. Instead use circular buffer. (just use the same array and wrap indexes) snip You might as well not use a string representation at all. At the beginning of the loop, calculate the

Re: Transforming a range back to the original type?

2012-05-03 Thread Stewart Gordon
On 02/05/2012 22:01, Jacob Carlborg wrote: Is there a general function for transforming a range back to the original type? If not, would it be possible to create one? To sum it up, it can't be done in the general case. The range API doesn't know or care about the underlying data structure.

Re: Docs: Section on local variables

2012-04-26 Thread Stewart Gordon
On 26/04/2012 08:26, Timon Gehr wrote: snip Another thing: It might not be unused in every static code path. One way to deal with this would be to do the checking before conditional compilation. That said, I've a feeling that mixin expansion might get in the way of this. Even more

Re: Docs: Section on local variables

2012-04-26 Thread Stewart Gordon
On 26/04/2012 08:26, Timon Gehr wrote: snip template isInputRange(R) { enum bool isInputRange = is(typeof( { R r; // can define a range object if (r.empty) {} // can test for empty r.popFront(); // can invoke popFront() auto h = r.front; // can declare an unused variable }())); } snip This is

Re: Docs: Section on local variables

2012-04-26 Thread Stewart Gordon
On 26/04/2012 15:05, Stewart Gordon wrote: snip http://d.puremagic.com/issues/show_bug.cgi?id=7989 From JMD: The fact that isInputRange and isForwardRange rely on declaring variables which aren't used being legal. It would be really annoying for unused local variables to be illegal when

Re: Docs: Section on local variables

2012-04-26 Thread Stewart Gordon
On 26/04/2012 22:52, bearophile wrote: snip For uncommon situations like isInputRange a specific annotation solves the problem cleanly. As does the compiler swallowing warnings in the content of an IsExpression as I already suggested. snip How many C/C++ programmers do you know that use

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 21/04/2012 19:24, H. S. Teoh wrote: snip In finished code, it's obviously a bad thing to have unused variables (unless the compiler optimizes them away, Whether the compiler optimises it away or not, an unused variable is a code smell. Complaining about unused variables serves as a warning

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 21/04/2012 17:26, Andrej Mitrovic wrote: snip Next thing you know the compiler will start warning me when I indent my code with uneven number of spaces! Or more usefully, warn if you have a mishmash of tab and space indentation. How do indent-sensitive languages (Haskell, Python, whatever

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 25/04/2012 17:10, Andrej Mitrovic wrote: On 4/25/12, Stewart Gordonsmjg_1...@yahoo.com wrote: Even if it's left over from debugging, it looks silly, and might lead other people reading the code to believe something's wrong. There's about a million ways to make code unreadable, and nobody

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 25/04/2012 21:12, Andrej Mitrovic wrote: snip I'm really only talking about: void a() { int x; } What is the distinction you're making exactly? And of course: void a() { bool state; ... if (state) { } } You mean an empty if body should trigger something? Or shouldn't? OK, so I can see

OT: Indent-sensitive languages again (was: Docs: Section on local variables)

2012-04-25 Thread Stewart Gordon
On 25/04/2012 12:30, Stewart Gordon wrote: On 21/04/2012 17:26, Andrej Mitrovic wrote: snip Next thing you know the compiler will start warning me when I indent my code with uneven number of spaces! Or more usefully, warn if you have a mishmash of tab and space indentation. How do indent

Re: Formatting dates in std.datetime?

2012-04-21 Thread Stewart Gordon
On 20/04/2012 21:29, H. S. Teoh wrote: Is there a way to format std.datetime.Date objects with a custom format string? My utility library has a datetime module with a custom formatting facility. http://pr.stewartsplace.org.uk/d/sutil/ The format string scheme is one of my own design, using

Re: Docs: Section on local variables

2012-04-21 Thread Stewart Gordon
On 20/04/2012 01:53, Andrej Mitrovic wrote: Can I remove this section from the D docs, in functions? : Local Variables It is an error to use a local variable without first assigning it a value. The implementation may not always be able to detect these cases. Other language compilers sometimes

Re: Clearly Label D1/D2/Tango/Phobos

2012-04-18 Thread Stewart Gordon
On 18/04/2012 13:34, Paul wrote: I bought the book and am trying to patiently learn this language. I follow various tutorials here and around the web that frequently won't compile. I suspect it has something to do with D1/D2/Phobos/Tango and not just really poor unvetted tutorials. It would

Re: T : T*

2012-04-18 Thread Stewart Gordon
On 13/04/2012 19:47, Jonathan M Davis wrote: I'd just like to verify that my understanding of T : T* in this template is correct: struct S(T : T*) snip it appears that the compiler is instead taking this to mean that the pointer part of the type should be stripped from the template argument's

Re: Multiple %s format specifiers with a single argument

2012-04-10 Thread Stewart Gordon
On 09/04/2012 18:35, Andrej Mitrovic wrote: On 4/9/12, Jonathan M Davisjmdavisp...@gmx.com wrote: Posix positional arguments seem to work for writefln but not format for whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877 Andrej, are emails from

Re: Multiple %s format specifiers with a single argument

2012-04-10 Thread Stewart Gordon
On 10/04/2012 13:30, Andrej Mitrovic wrote: On 4/10/12, Stewart Gordonsmjg_1...@yahoo.com wrote: Andrej, are emails from Bugzilla not getting through to you? I'm not getting any emails. Bugzilla stopped emailing me for quite a while now, I don't know why (except the monthly password

Re: SUL for Posix

2012-04-07 Thread Stewart Gordon
On 05/04/2012 14:51, Jacob Carlborg wrote: snip http://dlang.org/phobos/std_getopt.html But it might not do what you want. Where is the code in std.getopt that has any relevance whatsoever to what smjg.libs.util.datetime or smjg.libs.util.commandline is for? Stewart.

Re: SUL for Posix

2012-04-07 Thread Stewart Gordon
On 07/04/2012 17:54, Jacob Carlborg wrote: snip Both std.getopt and mjg.libs.util.commandline handle command line arguments? What's that to do with anything? If the code I need to finish smjg.libs.util.commandline is somewhere in std.getopt, please tell me where exactly it is. If it isn't,

Re: SUL for Posix

2012-04-07 Thread Stewart Gordon
On 07/04/2012 20:16, Jacob Carlborg wrote: snip I don't know what your module is supposed to do. Then how about reading its documentation? http://pr.stewartsplace.org.uk/d/sutil/doc/commandline.html If there's something you don't understand about it, this is the issue that needs to be

Re: Read a unicode character from the terminal

2012-04-04 Thread Stewart Gordon
On 31/03/2012 23:14, Stewart Gordon wrote: snip You might want to try the console module in my utility library: http://pr.stewartsplace.org.uk/d/sutil/ (For D1 at the moment, but a D2 version will be available any day now!) The D2 version is now up on the site. Jacob - would you be up

Re: Read a unicode character from the terminal

2012-04-04 Thread Stewart Gordon
On 04/04/2012 17:37, Jacob Carlborg wrote: snip Sure I can help you with testing. I have a lot on my own table so I don't have any time for implementing things (maybe some small things). If I may ask, what is the point of this library? Just to hold some miscellaneous utility

Re: Read a unicode character from the terminal

2012-03-31 Thread Stewart Gordon
On 31/03/2012 16:56, Jacob Carlborg wrote: How would I read a unicode character from the terminal? I've tried using std.cstream.din.getc but it seems to only work for ascii characters. If I try to read and print something that isn't ascii, it just prints a question mark. What OS are you

Making sense of ranges

2012-03-24 Thread Stewart Gordon
The documentation for std.range states http://dlang.org/phobos/std_range.html This module defines the notion of range (by the membership tests isInputRange, isForwardRange, isBidirectionalRange, isRandomAccessRange), range capability tests (such as hasLength or hasSlicing), and a few useful

Re: Making sense of ranges

2012-03-24 Thread Stewart Gordon
On 24/03/2012 18:57, Ali Çehreli wrote: snip Iterating an output range is also by popFront(). So what it says is, put this element to the output range and advance the range. There is a gotcha about this when the output range is a slice: Whatever is just put into the range is popped right away!

Re: Tail call optimization?

2012-03-19 Thread Stewart Gordon
On 18/03/2012 21:28, bearophile wrote: Alex Rønne Petersen Wrote: Does D to tail call optimization of any kind? The D standard doesn't require the D compiler to perform that optimization (unlike Scheme). Currently both DMD and LDC are able to perform tail call optimization in some normal

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Stewart Gordon
On 13/03/2012 23:14, Timon Gehr wrote: snip (Also, for associativity: Assign and OpAssign are right-associative and everything else is left-associative, correct?) Power is right-associative too. You forgot the conditional operator. And the relational operators are non-associative (a == b

Re: delegate as memeber

2012-02-25 Thread Stewart Gordon
On 21/02/2012 17:46, Jacob Carlborg wrote: On 2012-02-21 16:55, deadalnix wrote: snip You can implement a static opCall and use that instead of the constructor. But you don't have to call a static opCall. You can just declare a struct instance without any initialisation. Presumably half

Re: Hex floats

2012-02-16 Thread Stewart Gordon
On 16/02/2012 12:04, Don Clugston wrote: On 15/02/12 22:24, H. S. Teoh wrote: What's the original rationale for requiring that hex float literals must always have an exponent? For example, 0xFFi obviously must be float, not integer, so why does the compiler (and the spec) require an exponent?

Re: More octal questions

2012-02-15 Thread Stewart Gordon
On 15/02/2012 16:41, Jonathan M Davis wrote: snip They're not left over at all, and they have nothing to do with octal. snip They are something to do with octal: because in D an integer literal beginning with 0 is defined to be octal, the compiler must interpret them as such if it is going to

Re: Hex floats

2012-02-15 Thread Stewart Gordon
On 15/02/2012 21:33, H. S. Teoh wrote: On Wed, Feb 15, 2012 at 01:24:13PM -0800, H. S. Teoh wrote: [...] This is ambiguous, since you could interpret 0xFFp0F as either 0xFFp0 followed by the suffix 'F', or 0xFFp0F with an exponent of 0x0F no suffix. [...] Actually, nevermind that. I misread

Re: float.nan is not itself ?

2012-02-14 Thread Stewart Gordon
On 14/02/2012 15:39, Joshua Reusch wrote: Hello, why does this assertion fail: assert(float.nan == float.nan); there is the std.math.isNaN function which works correctly, but why can I not just use the comparison ? A NaN typically denotes some kind of invalid computation. If the results

Re: maketrans and translate

2012-02-13 Thread Stewart Gordon
On 13/02/2012 03:04, bearophile wrote: In the online docs I've seen that std.string.maketrans() is (going to be) deprecated. How do you adapt this code to the new regime? snip Use an associative array for the translation table. Or write your own functions that work in the same way as

Re: inout constructor?

2012-01-27 Thread Stewart Gordon
On 26/01/2012 15:27, Steven Schveighoffer wrote: snip auto tsm = TestStruct(xm); auto tsc = TestStruct(xc); auto tsi = TestStruct(xi); writeln(typeof(tsm).stringof); // TestStruct writeln(typeof(tsc).stringof); // const(TestStruct) writeln(typeof(tsi).stringof); // immutable(TestStruct) To

Re: Error: 'this' is only defined in non-static member functions, not parse

2012-01-17 Thread Stewart Gordon
For future reference and to elaborate on what others have said, if you're asking for help solving a problem with your code, then please: 1. Post a small, self-contained testcase that demonstrates the problem straight out of the box. Tips here: http://www.sscce.org/ 2. Post full compiler

Re: Taking a function or delegate as argument.

2012-01-10 Thread Stewart Gordon
On 10/01/2012 19:56, Jacob Carlborg wrote: snip A template parameter with a template constraint will accept any callable type. Function pointer, delegate, struct/class overloading the call operator and so on. Indeed, this is done in the C++ STL quite a lot. The drawback is that templated

Re: Taking a function or delegate as argument.

2012-01-10 Thread Stewart Gordon
On 10/01/2012 19:56, Jacob Carlborg wrote: snip A template parameter with a template constraint will accept any callable type. Function pointer, delegate, struct/class overloading the call operator and so on. Moreover, if you want to save the callback for later use, you need to distinguish

Re: An issue with lazy delegates

2012-01-09 Thread Stewart Gordon
On 05/01/2012 05:26, Andrej Mitrovic wrote: snip The first call doesn't do anything because the delegate is wrapped inside of another delegate. I want this template to be versatile enough to be used by both lazy expressions and delegate literals, but I don't know how. snip If you have a

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2012-01-06 Thread Stewart Gordon
On 29/12/2011 19:09, Jacob Carlborg wrote: snip excessive quote Could druntime hook up on the atexit function to run destructors and similar when the program exits? I'm not sure. Maybe it could be called upon to run static destructors and destruct heap-allocated objects. But in order to

Re: typedef deprecated - now what ?

2012-01-01 Thread Stewart Gordon
On 31/12/2011 13:34, Trass3r wrote: Basically it was deprecated because it's poorly defined and implemented. snip Would you care to elaborate? Moreover, if that's the only reason then why not improve it rather than getting rid of it? There are several types of typedefs that need to be

Re: typedef deprecated - now what ?

2011-12-31 Thread Stewart Gordon
On 30/12/2011 10:35, Stephan wrote: is there a template or something in phobos to get the same typesafe behaviour of good old typedef ? Could someone please provide a link to the thread with the reasons for deprecating typedef? There are too many threads with the words typedef and deprecate

Re: Void initialization

2011-12-20 Thread Stewart Gordon
On 19/12/2011 18:11, Steven Schveighoffer wrote: On Mon, 19 Dec 2011 12:24:18 -0500, Bear joanylepri...@yahoo.fr wrote: gc.malloc actually returns void[] http://www.d-programming-language.org/phobos/core_memory.html#malloc Looks like void* to me... Or is there another function I'm not

Re: Void initialization

2011-12-20 Thread Stewart Gordon
On 19/12/2011 12:12, bearophile wrote: Bear: snip float[] f = cast(float[])std.gc.malloc(x*4); Try something like this (untested): alias float TF; TF[] f = (cast(TF*)std.gc.malloc(x * TF.sizeof))[0 .. x]; snip I fail to see any real difference from the OP's code: - Why the alias? -

Re: Void initialization

2011-12-20 Thread Stewart Gordon
On 20/12/2011 18:12, bearophile wrote: snip Because in that code I have used three times a type (TF), auto allows to remove only one of them. The alias is not the best solution (a better solution is to put that code into a templated function), but repeating the same generic type more than one

Re: newbie question: Can D do this?

2011-12-20 Thread Stewart Gordon
On 20/12/2011 20:36, Philippe Sigaud wrote: snip That is, it expects some values, then string/values couples as associative arrays. snip I've a recollection of seeing something like this in the PHP library, but I forget where. I believe it's used in some functions that have a lot of options

Re: Void initialization

2011-12-20 Thread Stewart Gordon
On 20/12/2011 22:19, bearophile wrote: snip That's also why I have said a better solution is to wrap that code into a function template, so there is no need for an alias. snip So what you actually meant was to make TF a template parameter? That would make more sense. I can understand an

Re: writef %d of string

2011-12-04 Thread Stewart Gordon
On 02/12/2011 03:19, bearophile wrote: Stewart Gordon: It's perfectly legal code, If that code is legal, then in my opinion it's the rules of the language that are wrong and in need to be changed :-) You mean all programming languages should support CTFE for argument validation? What

Re: Formatted date

2011-12-01 Thread Stewart Gordon
On 03/11/2011 23:58, Lishaak Bystroushaak wrote: Hello. Is there any way how to format date with formating strings? snip Yes. See the datetime stuff in http://pr.stewartsplace.org.uk/d/sutil/ Stewart.

Re: Formatted date

2011-12-01 Thread Stewart Gordon
On 04/11/2011 00:51, Jonathan M Davis wrote: On Thursday, November 03, 2011 16:58 Lishaak Bystroushaak wrote: Hello. Is there any way how to format date with formating strings? Something like strftime in python; http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior Not

Re: writef %d of string

2011-12-01 Thread Stewart Gordon
On 12/10/2011 23:41, bearophile wrote: This code, that a sane language/language implementation refuses at compile-time, runs: It's perfectly legal code, so the best a compiler can correctly do is give a warning. Some C(++) compilers understand printf and will warn if the format string

Re: Formatted date

2011-12-01 Thread Stewart Gordon
On 01/12/2011 22:57, Jonathan M Davis wrote: snip There's a halfway decent chance that I posted in this thread prior to reading anything about your library or before I looked at it at all. And both Lishaak's and your computers had their clocks set several days fast at the time? Stewart.

Re: Make a variable single-assignment?

2011-11-30 Thread Stewart Gordon
On 21/11/2011 20:06, Jesse Phillips wrote: What you are describing is Head Const, and is not available. http://www.d-programming-language.org/const-faq.html#head-const It will not be added as it doesn't provide any guarantees about the code that is useful to the compiler. It can't be added to

Re: Assert allowed to have side effects?

2011-05-30 Thread Stewart Gordon
On 29/05/2011 14:03, bearophile wrote: Stewart Gordon: There are places where the spec fails to make a clear distinction between illegal code and incorrect code that the compiler may reject if it's smart enough. In D there are pure functions, so I think it's not too much hard for it to tell

Re: Assert allowed to have side effects?

2011-05-29 Thread Stewart Gordon
On 29/05/2011 09:44, simendsjo wrote: The documentation for assert, http://www.digitalmars.com/d/2.0/expression.html#AssertExpression, states that it's an error if the assert expression contains side effects, but it doesn't seem the compiler is enforcing this. There are places where the spec

Re: What is this strange alias syntax?

2011-05-23 Thread Stewart Gordon
On 22/05/2011 21:51, Timon Gehr wrote: snip I suspect what Andrej actually meant is to kill treating function signatures as types in this way. And possibly enhancement request rather than bug. It is the opposite of an enhancement request. It means removing a feature that cannot be

Re: What is this strange alias syntax?

2011-05-22 Thread Stewart Gordon
On 22/05/2011 11:57, Steven Schveighoffer wrote: On Sat, 21 May 2011 05:15:32 -0400, Simen Kjaeraas simen.kja...@gmail.com wrote: snip It's the old C syntax for defining function pointers. Well, without the pointer. And that last part is important, because the latter example is an array of

Re: .init of field == type's initializer or field initializer?

2011-05-21 Thread Stewart Gordon
On 20/05/2011 04:19, Andrej Mitrovic wrote: snip Foo.b.init is actually 0. Are the docs wrong, or is the compiler wrong? Let me know so I can fix the docs if necessary as I'm doing that now. Known issue: http://d.puremagic.com/issues/show_bug.cgi?id=5715 Stewart.

Re: toHash() and Interfaces

2011-05-11 Thread Stewart Gordon
On 06/05/2011 13:02, Steven Schveighoffer wrote: snip D has this horrible notion that any interface can be for a COM object, even though COM interfaces can only inherit from IUnknown (known statically). Therefore, interfaces that don't inherit from IUnknown are not considered Objects, even

Re: Shouldn't duplicate functions be caught by DMD?

2011-05-08 Thread Stewart Gordon
On 08/05/2011 09:41, bearophile wrote: Andrej Mitrovic: I think the compiler should check catch these mistakes at compile-time. I suggest to add an enhancement request in Bugzilla. Bugzilla entries are a form of voting by themselves too. snip One should not file stuff in Bugzilla without

Re: int or size_t ?

2011-05-08 Thread Stewart Gordon
On 07/05/2011 18:09, %u wrote: In Patterns of Human Error, the slide 31 point that you should replce int with size_t why that consider an error ? For those who aren't sure what this is on about: http://www.slideshare.net/dcacm/patterns-of-human-error But the short answer is because dim is a

Re: Next Release

2011-04-25 Thread Stewart Gordon
On 22/04/2011 20:48, Jonathan M Davis wrote: Well, then I'd better make sure that I get my most recent updates to std.datetime in soon. - Jonathan M Davis Does your library take into account that there's no year 0? Actually, for ISO 8601, which the library follows, there _is_ a year 0.

Re: What are delimited strings good for?

2011-04-11 Thread Stewart Gordon
On 10/04/2011 21:51, Jonathan M Davis wrote: snip If that had been `something instead of 'something, _then_ the delimited string becomes useful, but given how rarely backticks are needed, it does seem rather odd to have delimited strings just for that. So, I definitely have to wonder why they

Re: static variables for non-constant expressions?

2011-04-11 Thread Stewart Gordon
On 11/04/2011 02:37, Jonathan M Davis wrote: snip I don't know the background of how static variables really work, so is there a good reason why the first function can't work like the one below it? They have to be calculated at compile time so that ordering doesn't matter. If the order

Re: Unicode - Windows 1252

2011-03-18 Thread Stewart Gordon
On 16/03/2011 22:17, Tom wrote: I have a D2 code that writes some stuff to the screen (usually runs in cmd.exe pseudo-console). When I print spanish characters they show wrong (gibberish symbols and so, wich corresponds to CP-1252 encoding). Is there a way to convert all outputted streams to

Re: Read file/stream

2011-03-11 Thread Stewart Gordon
On 11/03/2011 18:46, Steven Schveighoffer wrote: snip I am not sure what facilities Phobos provides for reading/writing integers in network order (i.e. Big Endian), but I'm sure there's something. http://www.digitalmars.com/d/1.0/phobos/std_stream.html EndianStream I haven't experimented

Re: Read file/stream

2011-03-11 Thread Stewart Gordon
On 11/03/2011 19:50, Ali Çehreli wrote: snip There is also std.intrinsic.bswap Well spotted. I don't tend to look at std.intrinsic much. Presumably there's a reason that it's been provided for uint but not ushort or ulong Stewart.

Re: Read file/stream

2011-03-11 Thread Stewart Gordon
On 11/03/2011 21:51, Steven Schveighoffer wrote: snip Presumably there's a reason that it's been provided for uint but not ushort or ulong I think things in std.intrinsic are functions that tie directly to CPU features, True, but... so presumably, the CPU only provides the possibility

Re: Writing an integer to a file

2011-03-07 Thread Stewart Gordon
On 07/03/2011 12:11, %u wrote: this is part of the code: Posting the whole code (or even better, a minimal, complete program that shows the problem) helps a lot. void WritePushPop(cmd command, string segment, int index) { string temp = TextFile.Asm;

Re: Win7 64-bit

2011-03-06 Thread Stewart Gordon
On 01/03/2011 23:19, Dan McLeran wrote: never mind, i got it. i had to pass the switches: -D -unittest -cov life is hard. it's even harder when you're dumb. Would you care to enlighten the rest of us on what code you were using that requires those extra switches? Stewart.

Re: Pointer to Struct Pointer

2011-02-19 Thread Stewart Gordon
On 19/02/2011 13:18, Oliver wrote: Hello, I have the following code that works. What? The code you've posted doesn't work. I'd like to change the t tsData to ts tsData, but this does segfault. The code you've posted throws an AV, and correctly so. If you change tsData to a ts, it runs

Re: Opt-out polymorphism?

2011-02-18 Thread Stewart Gordon
On 13/02/2011 21:34, Sean Eskapp wrote: Is there a way to specify that a function is nonvirtual, but can still be overriden in base classes? e.g. Then you're not overriding at all. You're just declaring a function in the derived class that happens to have the same name. As such, it seems

Re: Read non-UTF8 file

2011-02-18 Thread Stewart Gordon
On 13/02/2011 21:49, Nrgyzer wrote: snip It compiles and works as long as the returned char-array/string of f.readLine() doesn't contain non-UTF8 character(s). If it contains such chars, writeln() doesn't write anything to the console. Is there any chance to read such files? Please post

Re: using a binary tree container

2011-02-18 Thread Stewart Gordon
On 11/02/2011 12:30, Dominic Jones wrote: snip Would that not be constructing an associated array? Whilst an associated array would do the job, there is no value for the key:value pair, just a list of keys. In the C++ STL there are the set and map containers. I want something like set. Dominic

Re: Verify tuple is a tuple of class objects?

2011-02-18 Thread Stewart Gordon
On 18/02/2011 21:22, Steven Schveighoffer wrote: snip template VerifyTuple(Types...) { static if(Types.length == 0) enum bool VerifyTuple = true; else enum bool VerifyTuple == is(Type : Object) VerifyTuple!(Types[1..$]); snip You have two typos there. Corrected version: enum bool

Re: opIn_r not detected

2011-02-12 Thread Stewart Gordon
On 10/02/2011 22:32, spir wrote: On 02/10/2011 07:43 PM, Stewart Gordon wrote: snip That got me thinking. It would appear that it auto-dereferences only the left operand. Try adding this to your code and see: writeln(s2 == sp); Works, indeed, but using opEquals on s2, and because s2

Re: Assigning Interface to Object

2011-01-16 Thread Stewart Gordon
On 16/01/2011 08:23, Jérôme M. Berger wrote: Stewart Gordon wrote: On 15/01/2011 17:44, Steven Schveighoffer wrote: snip Which unnecessarily complicates things. For example, you can't compare two interfaces (try it!). ? interface I {} ... I a = ...; I b = ...; if (a == b) //-- ERROR

Re: Assigning Interface to Object

2011-01-15 Thread Stewart Gordon
On 15/01/2011 17:44, Steven Schveighoffer wrote: snip Which unnecessarily complicates things. For example, you can't compare two interfaces (try it!). ?

Re: toDelegate() for D1

2011-01-14 Thread Stewart Gordon
On 13/01/2011 17:14, %u wrote: == Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article %ue...@ee.com wrote: I only need something to make a void deleg() from a void func(). This works for me: ReturnType!( F ) delegate( ParameterTypeTuple!( F ) ) toDelegate( F )( F fn ) { return

Re: Templated delegate

2011-01-10 Thread Stewart Gordon
On 10/01/2011 13:02, Mitja wrote: I would like to have a template which returns appropriate delegate, something like this: For what purpose? All you seem to have is a long-winded identity function. snip and compiled it like this: dmd mod2.d mod1.d, the program would produce segmentation

Re: Calling anonymous delegate recursively ?

2011-01-08 Thread Stewart Gordon
On 08/01/2011 16:00, Pelle wrote: snip http://en.wikipedia.org/wiki/Fixed_point_combinator#Y_combinator snip How are you getting around D not supporting recursively defined types? Stewart.

Re: Calling anonymous delegate recursively ?

2011-01-08 Thread Stewart Gordon
On 08/01/2011 17:40, Andrej Mitrovic wrote: snip Otherwise I'd really like the ability for a lambda to call itself. Perhaps a feature request is in order. I'm not sure what D would gain in practice. If you want a function that calls itself, why not just name the function? Stewart.

Re: undefined identifier getch()

2010-12-08 Thread Stewart Gordon
On 08/12/2010 11:06, Nrgyzer wrote: Hey guys, I'm writing a console based tool for windows. To receive the users input, I try to use getch() but the compiler always says Error: undefined identifier getch. When I use getchar() it compiles successfully, but getchar() doesn't returns after a

Re: undefined identifier getch()

2010-12-08 Thread Stewart Gordon
On 08/12/2010 13:25, Nrgyzer wrote: Okay, but what function can I use to get the pressed key? kbhit/_kbhit seems to do what I want, but hwo can I use it in D? I always get the error, that kbhit (or similar functions) are not available. snip kbhit just tests whether there's a keystroke waiting

Re: unpacking

2010-12-07 Thread Stewart Gordon
On 07/12/2010 17:29, spir wrote: Hello D people, Is there a way to unpack an array into local vars, as: auto x = [1,2,3]; a,b,c = x; import std.stdio; void unpack(A, T...)(out T vars, A data) { assert (vars.length == data.length); foreach (i, v; vars) {

Re: array of elements of various subclasses

2010-11-07 Thread Stewart Gordon
On 07/11/2010 15:49, spir wrote: snip And I'd like to know, as a possible workaround, if there is a way to save a variadic arg list: class C { ??? xs; this(X xs...) { this.xs = xs; } } What exactly are you trying to do here?

Re: how to initialize immutable 2 dim array

2010-10-31 Thread Stewart Gordon
On 31/10/2010 17:10, Michal Minich wrote: I have global static array and I want it to initialize in module constructor, but I get error. I there way to do it without using enum. So you want to initialise it with data acquired at runtime, but make it immutable once initialised? immutable

Re: delete an element from an array

2010-10-24 Thread Stewart Gordon
On 24/10/2010 12:24, Adam Cigánek wrote: remove removes element at a given offset. I want to remove element with a given value. This is example shows it better: snip Your new example doesn't show it better, it's the only one you've given that shows it at all. What you had originally was

Re: exception types objects

2010-10-21 Thread Stewart Gordon
On 19/10/2010 23:23, Jonathan M Davis wrote: snip Perhaps, but there is no real benefit in throwing anything other than an Exception (or Error upon occasion) and if we allow you to throw anything than catch(Exception e) won't catch them all. It also would pretty much violate nothrow since

Re: Copying a delegate

2010-09-19 Thread Stewart Gordon
On 19/09/2010 04:35, Jonathan M Davis wrote: snip That doesn't work because you're just copying the pointer. Is there a way to actually do a deep copy of the delegate? I can see why this would be problematic if the delegate had reference types in its scope (since presumably, they'd have to be

Re: Translation of C function pointer.

2010-09-16 Thread Stewart Gordon
On 16/09/2010 15:06, BCS wrote: Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs: void function() function(sqlite3_vfs*, void*, const const(char*) zSymbol) D,

Re: Translation of C function pointer.

2010-09-16 Thread Stewart Gordon
On 16/09/2010 15:37, Steven Schveighoffer wrote: On Thu, 16 Sep 2010 10:06:24 -0400, BCS n...@anon.com wrote: Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs:

Re: Formating decimal numbers with commas (1,000.00)

2010-09-14 Thread Stewart Gordon
On 14/09/2010 21:00, jicman wrote: Greetings. I have been trying, for more than an hour, to get information on how to format a number (2342.23) to $2,342.23. Just wondering, where have you been searching for this information? I can write a little function to do this, but doesn't format

Re: String literals have only one instance?

2010-08-19 Thread Stewart Gordon
Jonathan Davis wrote: snip You can always check with the is operator though. If it reports true, then the two strings have the same instance. If it reports false, then they don't. I can't see how testing each string literal to see if it's the same instance as another can work. The OP's

Re: string[int[][]] ??

2010-07-24 Thread Stewart Gordon
dcoder wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article This is what I think you should use: string[int[2]] snip board[[0,0]] = Rook; Further to what others have said, why use strings? There are only 12 possible chess pieces (black and white), plus blank, so

Re: Mixing operations with signed and unsigned types

2010-07-08 Thread Stewart Gordon
Ellery Newcomer wrote: On 07/06/2010 07:05 PM, Stewart Gordon wrote: snip Just using uint, of course! For enforcing a non-negative constraint, that is brain damaged. Semantically, the two are very different. So effectively, the edit wars would be between people thinking at cross purposes

  1   2   >