Re: Thread.sleep( dur!(msecs)( 50 ) ); // sleep for 50 milliseconds

2015-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/15 12:49 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Friday, January 30, 2015 12:30:35 FG via Digitalmars-d-learn wrote: On 2015-01-30 at 12:08, Vladimir Panteleev wrote: On Friday, 30 January 2015 at 11:04:47 UTC, FG wrote: Bug or correct behaviour? Bug:

Re: Time from timestamp?

2015-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/15 5:18 PM, Chris Williams wrote: I'm attempting to print a human-readable version of a timestamp. The timestamp is coming from an external service, via JSON. An example is: 1421865781342 Which I know to be: 2015-01-21T18:43:01.342Z

Re: for ranges

2015-01-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/23/15 4:44 AM, ixid wrote: On Thursday, 22 January 2015 at 16:41:49 UTC, Russel Winder wrote: Playing with factorial implementations, as you do. I had a D implementation using ulong. Not sensible obviously since overflow is a bit of a problem. But the code worked, as did the tests. Now

Re: why spawn crash?

2015-01-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/22/15 10:20 PM, mzf wrote: i wrote a test code: void worker(int firstNumber) { Thread.sleep(1.msecs); } void main() { foreach (i; 1 .. 1000) { spawn(worker, i ); writeln(i); } thread_joinAll(); writeln(ok); } sometimes it's ok,sometimes

Re: Deducing a template retrun parameter type based on an assignment?

2015-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/15 5:06 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Friday, 30 January 2015 at 08:52:41 UTC, bearophile wrote: Jeremy DeHaan: I figured that it would be smart enough to deduce the parameter type based on the type that it was trying to be assigned to. For that you

Re: casting SysTime to ubyte[]

2015-01-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/12/15 8:59 AM, Laeeth Isharc wrote: import std.datetime; import std.stdio; import std.conv; void main(string[] arg) { auto a=Clock.currTime(); auto b=cast(ubyte[])a; writefln(%s,b); } how do i get the time as a binary representation I can write to a file? You can always

Re: Cast a struct to void*

2015-01-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/9/15 1:50 PM, John Colvin wrote: On Friday, 9 January 2015 at 18:35:56 UTC, anonymous wrote: On Friday, 9 January 2015 at 18:25:42 UTC, John Colvin wrote: struct S { void* p; } void main() { S s; auto a = cast(void*)s; //Error: e2ir: cannot cast s of type S to type void* This

Re: Classes and @disable this()

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/8/15 2:57 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, February 08, 2015 17:51:09 bearophile via Digitalmars-d-learn wrote: fra: However making it a compiler error would be far, far better I think this can be filed in Bugzilla as diagnostic enhancement: class Foo {

Re: Static method of inner class needs this

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/9/15 4:30 AM, ketmar wrote: On Mon, 09 Feb 2015 07:32:32 +, rumbu wrote: class Outer { class Inner { static Inner createInner() { return new Inner(); //need 'this' to access member this } } } Is this a bug? strictly speaking,

Re: dmd-2.067.0-b1

2015-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/15 7:38 AM, tcak wrote: On Friday, 13 February 2015 at 09:38:04 UTC, Dennis Ritchie wrote: This is a bug? import std.stdio; void main() { int a = 0; writeln( (a 10) ? a = 1 : a = 2 );// prints 2 writeln( (a 10) ? a = 1 : (a = 2) ); // prints 1 } Even C++ output:

Re: dmd-2.067.0-b1

2015-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/15 9:01 AM, anonymous wrote: On Friday, 13 February 2015 at 13:25:55 UTC, Steven Schveighoffer wrote: Yes, the operator precedence (curiously not defined in the spec) is here: http://wiki.dlang.org/Operator_precedence Conditional operator is above assignment operators. It's

Re: Classes and @disable this()

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/9/15 3:15 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, February 09, 2015 13:29:22 Steven Schveighoffer via Digitalmars-d-learn wrote: On 2/8/15 2:57 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, February 08, 2015 17:51:09 bearophile via Digitalmars-d

Re: I can has @nogc and throw Exceptions?

2015-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/15 2:03 PM, Jonathan Marler wrote: This question comes from wanting to be able to throw an exception in code that is @nogc. I don't know if it's possible but I'd like to be able to throw an exception without allocating memory for the garbage collector? You can do it in C++ so I think

Re: I can has @nogc and throw Exceptions?

2015-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/15 4:08 PM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Friday, 13 February 2015 at 19:09:43 UTC, Tobias Pankrath wrote: 1. Throw preallocated exceptions is the way to go and because noone has yet shown an explicit example: void myThrowingNogcFunc() @nogc {

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/8/15 12:15 AM, Meta wrote: On Wednesday, 7 January 2015 at 23:27:19 UTC, anonymous wrote: Don't do this without `dup`ing. Quoting the documentation: Oh, whoops. I thought those special variadic args were always allocated on the heap. Nope, Which makes it annoying, what if the argument

Re: What does dmd 2.066 want from me?

2015-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/7/15 3:10 PM, Artem Tarasov wrote: I'm trying to compile my software with the latest compiler, and it spits out the following error: $ make ... rdmd --force --build-only -IBioD -g -L-Lhtslib -L-l:libhts.a -L-l:libphobos2.a -ofbuild/sambamba.o main.d ...

Re: Can pointers to values inside associative arrays become invalid?

2015-01-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/6/15 12:39 PM, Idan Arye wrote: On Tuesday, 6 January 2015 at 16:30:14 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Jan 06, 2015 at 04:18:17PM +, Idan Arye via Digitalmars-d-learn wrote: I have an associative array, and I use the `in` operator to get a reference to a value

Re: Disallow destroy(structPtr)?

2015-02-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/15 1:05 PM, Nick Treleaven wrote: Hi, The following code is supposed to destroy the struct instance: import std.stdio; struct S{ ~this(){destruct.writeln;} } auto p = new S; destroy(p); end.writeln; It works correctly if I use destroy(*p),

Re: Cycle detected between modules with ctors/dtors

2015-03-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/4/15 4:15 PM, rumbu wrote: On Wednesday, 4 March 2015 at 16:08:00 UTC, Steven Schveighoffer wrote: curiously not listed? That doesn't make any sense. If there is not a cycle in the listed modules, where at least 2 modules have a static ctor or static dtor, then there is a bug in the

Re: problems with std.bitmanip.append (bug?)

2015-03-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/26/15 6:07 AM, Hugo wrote: On Thursday, 26 March 2015 at 02:39:56 UTC, Steven Schveighoffer wrote: An array as an output range writes to the front. You can use std.array.Appender to get appending behavior. I know, it's weird. Alternatively, you can add more bytes to the array, and append

Re: D1 operator overloading in D2

2015-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/15 1:42 AM, ketmar wrote: it's still working. moreover, it is used in Phobos! and yet it's not documented anywhere. what i want to know is whether they will be removed for good, or brought back and properly documented? the current situation is awful: compiler has special treatment for

Re: Passing myself, a struct, as a C callback context

2015-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/15 5:12 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: I'm registering a callback with some C code. The simplified story is here, but the actual code is on GitHub [1] at the end if you care. The call looks

Re: rvalue based copy

2015-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/15 1:09 PM, matovitch wrote: Hi, Surely I am misunderstanding something. I got something like this : struct S { void opAssign(const ref s) { //... } } S genS() { S s; //... return s; } main() { S s; s = genS(); } DMD says :

Re: rvalue based copy

2015-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/15 1:42 PM, matovitch wrote: On Monday, 30 March 2015 at 17:21:53 UTC, Steven Schveighoffer wrote: Annoying as this is (and blatantly awkward), it saves you from having to implement twice: void opAssign(T)(auto ref const T s) if(is(T == S)) {...} Yep, this seems awkward to me too

Re: struct variable initialized with void.

2015-03-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/31/15 11:23 AM, Adam D. Ruppe wrote: On Tuesday, 31 March 2015 at 15:12:54 UTC, ref2401 wrote: Could anyone describe me what this initialization does, please? It skips the initialization entirely, leaving the memory random instead of making it zeroes (or NaN or whatever the .init is of

Re: On opCmp

2015-03-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/2/15 8:52 AM, Nordlöw wrote: On Friday, 27 February 2015 at 15:00:35 UTC, Steven Schveighoffer wrote: Hm... what about: return count rhs.count ? -1 : count rhs.count ? 1 : rank rhs.rank ? -1 : rank rhs.rank; Is this more efficient than my version? You said more compact, not more

Re: @trusted and return ref

2015-03-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/2/15 3:38 AM, Kagamin wrote: On Friday, 27 February 2015 at 14:52:56 UTC, Steven Schveighoffer wrote: The counter is freed in the destructor, nothing can happen after that. So the code is now etched in stone and cannot be changed? Is there an attribute for that? :P Changes introduces

Re: @trusted and return ref

2015-02-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/27/15 3:29 AM, Kagamin wrote: On Thursday, 26 February 2015 at 16:25:59 UTC, Steven Schveighoffer wrote: However, we have an issue here. At any point inside the code, you could do: oldcount = count; And now, there is still potentially a dangling pointer somewhere. This means every place

Re: On opCmp

2015-02-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/27/15 6:04 AM, Nordlöw wrote: Is there a more compact way to describe the opCmp function in the following struct struct Hit { size_t count; // number of walkers that found this node NWeight rank; // rank (either minimum distance or maximum strength) auto opCmp(const Hit

Re: Cycle detected between modules with ctors/dtors

2015-03-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/3/15 12:40 PM, rumbu wrote: I encountered the following error: First-chance exception: object.Exception Aborting: Cycle detected between modules with ctors/dtors: system.globalization - internals.locale - system.runtime.interopservices - system.io - system.globalization at

Re: Filling a char array with letters and element type of char[]

2015-03-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/3/15 2:32 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, March 03, 2015 08:50:35 Steven Schveighoffer via Digitalmars-d-learn wrote: What is the type of char array holds why it does not matches char? Because D is schizophrenic ;) Phobos considers char[] arrays

Re: Cycle detected between modules with ctors/dtors

2015-03-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/3/15 4:24 PM, rumbu wrote: On Tuesday, 3 March 2015 at 18:55:49 UTC, Steven Schveighoffer wrote: Only one of the listed modules has a static contructor (system.globalization) and that constructor doesn't use any information from other modules. It's a complex problem. Because we don't

Re: Filling a char array with letters and element type of char[]

2015-03-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/3/15 4:06 AM, Tobias Pankrath wrote: I have three questions? If I change the iterator which I get from algorithm, the owner data will change or not? I'm not sure about this question. How to use std.algorithm.fill with char types? You cannot currently. What is the type of char

Re: @trusted and return ref

2015-03-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/3/15 9:28 AM, Kagamin wrote: If one wants to prevent a leak, then counter can be wrapped --- struct Unsafe(T) { private T _payload; T payload() @system { return _payload; } alias payload this; } --- And somehow disallow Unsafe template in safe function signatures, then having

Re: To GC or Not To GC in std.container.*

2015-02-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/23/15 3:16 PM, Nordlöw wrote: On Monday, 23 February 2015 at 19:24:32 UTC, Steven Schveighoffer wrote: In answer to your question, RBNode should not be accessible direction outside of RedBlackTree. But we don't have allocators inside of Phobos, so I used the easiest thing I could for

Re: To GC or Not To GC in std.container.*

2015-02-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/15 4:26 PM, Nordlöw wrote: What's the policy on using GC or not in std.container.* ? - std.container.Array uses malloc for its allocation but - RedBlackTree.allocate() returns a: new RBNode!Elem* Is this because RBNode* should be reachable outside of RedBlackTree or is this a todo?

Re: @trusted and return ref

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/24/15 5:37 PM, Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= ola.fosheim.grostad+dl...@gmail.com wrote: Since neither Andrei or Walter are able to say something sensible on these issues when asked, I apparently need to learn something about the consistency of C memory safety. I'm happy to listen to

Re: DList.Range magically becomes empty.

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/26/15 11:07 AM, Tobias Pankrath wrote: On Thursday, 26 February 2015 at 15:57:22 UTC, Steven Schveighoffer wrote: On 2/25/15 4:58 AM, Ivan Timokhin wrote: Tobias Pankrath wrote: writefln(stack: %s, stack[]); //fine This call consumes all ranges stored in stack, so they're empty

Re: Opening temporary files for std.process.spawnProcess input/output

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/15 2:09 PM, Ali Çehreli wrote: It looks like the file is closed when spawnProcess is finished. I don't know whether it is done by spawnProcess explicitly or whether it is a behavior for temporary files. I know the problem is solved, but I wanted to chime in with some explanation

Re: Why rbtree.length isn't const?

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/26/15 3:20 AM, drug wrote: Is it intended by some reason? No, it can be fixed. RBTree was not written to support const because D doesn't support tail-const ranges, which makes const really difficult to deal with. But length can definitely be const. Please submit an issue.

Re: DList.Range magically becomes empty.

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/15 4:58 AM, Ivan Timokhin wrote: Tobias Pankrath wrote: writefln(stack: %s, stack[]); //fine This call consumes all ranges stored in stack, so they're empty afterwards. This has to be a bug. stack[] should produce a range that can be iterated without destroying the data in

Re: static void arrays under garbage control?

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/15 8:15 PM, captaindet wrote: if i understand correctly, static arrays are exempt from GC scanning for memory pointers http://dlang.org/garbage.html : Pointers in D can be broadly divided into two categories: Those that point to garbage collected memory, and those that do not. Examples

Re: static void arrays under garbage control?

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/26/15 11:57 AM, captaindet wrote: On 2015-02-26 10:07, Steven Schveighoffer wrote: Static data I believe is always scanned conservatively because no type information is stored for it ever, even on allocation (i.e. program startup). ouh, the confusion goes on... are you saying that {

Re: static void arrays under garbage control?

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/26/15 2:28 PM, Ali Çehreli wrote: On 02/26/2015 10:07 AM, Steven Schveighoffer wrote: // will not be scanned by GC for pointers: void[] buffer4 = cast(void[])(new ubyte[16]); uint[] buffer5 = cast(uint[])(new ubyte[16]); Correct, since they are allocated as

Re: @trusted and return ref

2015-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/26/15 3:49 PM, Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= ola.fosheim.grostad+dl...@gmail.com wrote: On Thursday, 26 February 2015 at 16:25:59 UTC, Steven Schveighoffer wrote: First, malloc should be safe, in the same way new is safe. If it is typed and do the sizeof... Right, one can easily

Re: Format double in decimal notation without trailing zeros after the decimal point

2015-03-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/27/15 11:02 AM, akaDemik wrote: The task seemed very simple. But I'm stuck. I want to: 1234567890123.0 to 1234567890123 1.23 to 1.23 1.234567 to 1.2346. With format string %.4f i get 1.2300 for 1.23. With %g i get 1.23456789e+12 for 1234567890123.0. I can not believe that it is not

feature request for dlang.org library preview

2015-03-26 Thread Steven Schveighoffer via Digitalmars-d-learn
So I just noticed, when I click on source code button for a function in dlang.org library preview, it brings me to the source code as of that release, but to the file itself (on github). I'd like it to go to the specific line where that function is defined instead. I'm not sure if we need

Re: problems with std.bitmanip.append

2015-03-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/25/15 1:29 PM, Hugo wrote: On Wednesday, 25 March 2015 at 17:09:05 UTC, John Colvin wrote: As per the signature in the docs: void append(T, Endian endianness = Endian.bigEndian, R)(R range, T value) The endianness is the second template argument. What you need to write is

Re: Garbage collector collects live objects

2015-03-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/25/15 9:51 AM, Ali Çehreli wrote: On 12/09/2014 08:53 AM, Steven Schveighoffer wrote: On 12/9/14 11:17 AM, ketmar via Digitalmars-d-learn wrote: that file can be already finalized. please remember that `~this()` is more a finalizer than destructor, and it's called on *dead* object.

Re: Mistake of opening of a file having a name in cp1251.

2015-04-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/3/15 2:26 AM, MGW wrote: Greetings to all! I work on Windows with cp1251 and I have a mistake in the program: import std.stdio; int main (string [] args) { string nameFile = `«Ёлки с объектами №876».txt`; File f = File (nameFile, w); f.writeln (Greetings!); return 0; }

Re: D1 operator overloading in D2

2015-04-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/15 11:25 AM, Steven Schveighoffer wrote: I'll put in a doc PR to reference the D1 documentation. https://github.com/D-Programming-Language/dlang.org/pull/953 -Steve

Re: how does isInputRange(T) actually work?

2015-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/21/15 3:11 PM, John Colvin wrote: On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote: enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if (r.empty) {} // can test for empty r.popFront(); // can

Re: User input readline || readf

2015-04-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/23/15 1:17 PM, kerze wrote: The problem is, it writes instant Name: Age: at the standart output. readf reads the element from the stream, and NOTHING MORE, it leaves the newline on the stream. So the next readf then reads the newline as a string. You can fix this by using readf( %s),

Re: SysTime.toISOExtString with timezone offset

2015-04-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/20/15 4:47 AM, Jonathan M Davis via Digitalmars-d-learn wrote: Perhaps, LocalTime should be changed so that it prints the time zone out (and just make it so that the lack of time zone is read in as local time rather than treating it that way in both directions), but that's not how it works

Re: Startup files for STM32F4xx

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/23/15 11:30 AM, Jens Bauer wrote: On Thursday, 23 April 2015 at 12:14:59 UTC, Steven Schveighoffer wrote: You can't use something like this? http://www.floodgap.com/software/tenfourfox/ Wow, I thought they stopped making builds at v20! -I'm pretty sure they said on the Web-site that

Re: function ref param vs pointer param

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 9:23 AM, ref2401 wrote: What advantages do ref params give over pointer params? struct MyStruct { string str; this(string str) { this.str = str; } } void processRef(ref MyStruct ms) { writeln(processRef: , ms); } void processPointer(MyStruct* ms) {

Weird OSX issue

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
OK, so I think I found a bug, but I have no idea how to reproduce it. It seems to be dependent on environment. Here is an annotated (using # for comments) session to show you the weirdness. All versions are 2.067, and I did use dmd -v to make sure rogue dmd.conf or library files are not

Re: __gshared static

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 1:22 PM, =?UTF-8?B?Ik3DoXJjaW8=?= Martins\ marcio...@gmail.com\ wrote: Hi! I just stumbled across what seems like a misunderstanding on my side about these keywords. Can someone help clarify these for me? ``` __gshared static int foo; __gshared int foo; ``` What are the storage and

Re: Convert hex to binary

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 2:14 PM, nrgyzer wrote: Hi, I'm looking for a function that converts my hex-string to a binary representation. In Python I write the following: myHex = 123456789ABCDEF myBin = myHex.decode('hex') But how to do the same in D? Is there any function? Thanks for suggestions! import

Re: Startup files for STM32F4xx

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 7:42 PM, Jens Bauer wrote: On Friday, 24 April 2015 at 22:18:22 UTC, tom wrote: ill order a discover, i have to try this out. http://www.digikey.com/product-detail/en/STM32F4DISCOVERY/497-11455-ND/2711743 this one right? This board will do nicely, but you may want to get a

Re: No line numbers in compiler error messages

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 1:20 PM, John Nixon wrote: I am using dmd v2.067.0 on Mac OSX with Terminal and I found the lack of line numbers surprising. Is there something simple I am doing wrong? Do any of the switches on the command line do this? It does post line numbers. Please post source and compile line

Re: Startup files for STM32F4xx

2015-04-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/23/15 5:54 AM, Jens Bauer wrote: On Thursday, 23 April 2015 at 04:59:47 UTC, Rikki Cattermole wrote: On 23/04/2015 4:53 p.m., Jens Bauer wrote: On Thursday, 23 April 2015 at 04:48:16 UTC, Rikki Cattermole wrote: Ehh, maybe you should setup a e.g. vm of e.g. Linux Mint and use e.g. Github

Re: Converting Java code to D

2015-04-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/20/15 11:28 AM, Mike James wrote: Here is a fragment of Java code from an SWT program... public enum LineStyle { NONE(None), SOLID(Solid), DASH(Dash), DOT(Dot), DASHDOT(Dash Dot), DASHDOTDOT(Dash Dot Dot); public final String label; private

Re: User defined properties signatures

2015-04-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/20/15 2:50 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, April 20, 2015 18:35:34 dvic via Digitalmars-d-learn wrote: Why is the compiler not complaining about defining 2 read properties and it does otherwise when using both of them? Now, that is weird. I would fully

Re: __gshared static

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 2:47 PM, bearophile wrote: Steven Schveighoffer: These are the same, __gshared overrides static. Isn't forbidding __gshared static a good idea then, to avoid user confusion? Surely, prohibiting non-functioning attributes is good when it's obvious that they do nothing. BUT...

Re: No line numbers in compiler error messages

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 2:24 PM, Jesse Phillips wrote: On Friday, 24 April 2015 at 17:20:12 UTC, John Nixon wrote: I am using dmd v2.067.0 on Mac OSX with Terminal and I found the lack of line numbers surprising. Is there something simple I am doing wrong? Do any of the switches on the command line do this?

Re: Convert hex to binary

2015-04-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/24/15 2:50 PM, nrgyzer wrote: On Friday, 24 April 2015 at 18:45:55 UTC, Jesse Phillips wrote: On Friday, 24 April 2015 at 18:14:07 UTC, nrgyzer wrote: Hi, I'm looking for a function that converts my hex-string to a binary representation. In Python I write the following: myHex =

Re: Weird OSX issue

2015-04-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/25/15 3:07 AM, Dan Olson wrote: Jacob Carlborg d...@me.com writes: On 2015-04-24 20:37, Steven Schveighoffer wrote: So am I going crazy? Or is dmd doing things differently depending on where its environment is? Any compiler gurus out there understand why the symbol is different? I

Re: shouldn't this code at least trigger a warning?

2015-04-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/29/15 5:25 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Wednesday, 29 April 2015 at 06:37:44 UTC, ketmar wrote: subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break;

Re: Weird OSX issue

2015-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/27/15 9:54 AM, Steven Schveighoffer wrote: So I think the issue here is that the pkg installer on OSX does not clean up the target directory if it already exists (or at least purposely remove thread.di). Will look into fixing that. At least now, it works properly, thanks (did a rm -rf

Re: Returning an empty range of a given type

2015-05-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/13/15 10:58 PM, rcorre wrote: Actually, this doesn't even seem to work with a custom range: import std.range; import std.stdio; import std.algorithm; struct MyContainer { @nogc auto opSlice() { struct Range { @property bool empty() { return true; }

Re: Returning an empty range of a given type

2015-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/14/15 11:22 PM, rcorre wrote: On Thursday, 14 May 2015 at 18:44:58 UTC, Steven Schveighoffer wrote: It depends on the guts of MyContainer.Range. I'm assuming MyContainer.Range has SOME sort of references (i.e. pointers) to the data in the container, so why not just have: bool empty() {

Re: SIG11 crashing - can't figure it out

2015-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/15/15 7:08 AM, Rob =?UTF-8?B?UGlla8OpIg==?= robpi...@gmail.com wrote: Working my way through Ali Çehreli's rather amazing e-book, I've hit a snag where some code I've written is pretty crashy. I consistently get Segmentation fault: 11 (dmd 2.067.1, OSX). Using dustmite (and 2.067.0), I

Re: Deprecation

2015-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/15/15 12:50 PM, Manfred Nowak wrote: 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? That seems like a bug. I think super being an lvalue in this

Re: The analogue of fill-pointer in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 1:43 PM, Ali Çehreli wrote: On 05/18/2015 05:26 AM, John Colvin wrote: On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers! It's exactly the

Re: The analogue of fill-pointer in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 6:24 AM, Dennis Ritchie wrote: On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote: On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5): http://www.tutorialspoint.com/lisp/lisp_arrays.htm Does D

Re: 'const' and 'in' parameter storage classes

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/15/15 2:19 PM, ref2401 wrote: On Friday, 15 May 2015 at 16:30:29 UTC, Steven Schveighoffer wrote: On 5/15/15 12:04 PM, ref2401 wrote: What is the difference between 'const' and 'in' parameter storage classes? When should I use 'const' or 'in'? The documentation says 'in' is the same as

Re: How to create a mutable array of strings?

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 9:55 AM, Dennis Ritchie wrote: On Monday, 18 May 2015 at 13:14:38 UTC, Steven Schveighoffer wrote: It's annoying to have to dup each one. Yes, it's really annoying. However, the problem can be solved as follows:

Re: How to create a mutable array of strings?

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/17/15 5:15 AM, Dennis Ritchie wrote: This option is also a strange: char[][] s = [foo.dup, bar.dup]; s[1][1] = 't'; In my opinion, you need to add to D keyword mutable. It's annoying to have to dup each one. But, you do have a couple other possibilities: auto s = [foo.dup, bar.dup];

Re: The analogue of fill-pointer in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 2:40 PM, Ali Çehreli wrote: On 05/18/2015 11:19 AM, John Colvin wrote: On Monday, 18 May 2015 at 17:43:50 UTC, Ali Çehreli wrote: On 05/18/2015 05:26 AM, John Colvin wrote: On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis

Re: The analogue of fill-pointer in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 2:45 PM, Ali Çehreli wrote: Exactly! That recent discovery of mine made me come up with this guideline: Never append to a parameter slice. I think this may not be an appropriate guideline. It's perfectly fine to append to a parameter slice. You just need to leave it the way you

Re: 'const' and 'in' parameter storage classes

2015-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/15/15 12:04 PM, ref2401 wrote: What is the difference between 'const' and 'in' parameter storage classes? When should I use 'const' or 'in'? The documentation says 'in' is the same as 'const scope' but I can't write 'const scope ref' though it's legal to write 'in ref'. scope ref const

Re: Converting void* to D array

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 8:35 AM, CraigDillabaugh wrote: On Wednesday, 15 April 2015 at 11:18:03 UTC, Steven Schveighoffer wrote: immutable blocksize = GByte.sizeof * x_block_size * y_block_size; auto buffer = malloc(blocksize)[0..blocksize]; Also, you don't need to cast pointers to void *. Should be able

Re: Converting void* to D array

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 11:02 AM, CraigDillabaugh wrote: Nice. Thanks. I didn't realize you can slice a bare pointer like that. Does druntime have any way of making sure that is safe, or are you on your own? No, druntime cannot know what the pointer actually points at. This would not work in @safe

Re: CT-String as a Symbol

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 6:42 PM, Nordlöw wrote: On Wednesday, 15 April 2015 at 20:12:27 UTC, Ali Çehreli wrote: Ali I cracked it: Reason: I hade a failing unittest using it as auto xs = x.indexedBy!I; which I changed to auto xs = x.indexedBy!Ix; For some reason the mixin magic becomes

Re: Linking C++ standard library works with GDC... but not DMD. (Linux)

2015-04-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/16/15 4:51 AM, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get errors involving the

Re: Invalid Floating Point Operation (DMD 2067)

2015-04-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/16/15 10:23 AM, ref2401 wrote: Hi Everyone, After I switched to DMD 2067 my code that previously worked began crashing. If I change the return statement in the matrixOrtho function from: return Matrix(...); to: Matrix m = Matrix(...); return m; then the error won't occur

Re: Printing an std.container.Array

2015-04-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/16/15 4:18 PM, Panke wrote: Yep, but problem is almost no one expect this, or know this. We definitely should do better. How? By doing what is expected. Print the array contents. See my new comment in that PR. -Steve

Re: Invalid Floating Point Operation (DMD 2067)

2015-04-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/16/15 4:32 PM, rumbu wrote: On Thursday, 16 April 2015 at 20:27:46 UTC, rumbu wrote: Hit send by accident :) Reduced case: struct S { float f; //or double or real this(float f) { this.f = f; } } S foo() { return S(0f); } void main() { auto s = foo(); }

Re: Printing an std.container.Array

2015-04-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/16/15 5:18 PM, Dennis Ritchie wrote: On Thursday, 16 April 2015 at 20:34:19 UTC, Steven Schveighoffer wrote: On 4/16/15 4:18 PM, Panke wrote: Yep, but problem is almost no one expect this, or know this. We definitely should do better. How? By doing what is expected. Print the array

Re: Auto ref function : How is this possible ?

2015-04-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/11/15 6:08 AM, matovitch wrote: Hi, I just learn about auto ref functions and tried this : import std.stdio; auto ref foo(int i, ref float f) { if (i f) { return i; } else { return f; } } void

Re: std.array.split - Template instantiating error

2015-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/18/15 4:18 AM, nrgyzer wrote: array.d(1510): Error not a property splitter(range, sep).array sample.d(6): Error template instance std.array.split!(string, char) error instantiating Are you using -property switch? Looks like std.array does not obey property switch requirements. I

Re: Converting void* to D array

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 12:47 AM, Daniel Kozak wrote: On Wednesday, 15 April 2015 at 04:43:39 UTC, Daniel Kozák wrote: On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi. I want to call a C library function that returns a data buffer as

Re: UFCS and overloading

2015-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/15 12:23 PM, Szymon Gatner wrote: Hi, I am surprised that this doesn't work: class Foo { void bar(string) {} } void bar(Foo foo, int i) { } auto foo = new Foo(); foo.bar(123); // === error causing compilation error: main.d(24): Error: function main.Foo.bar (string _param_0) is

Re: UFCS and overloading

2015-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/15 2:00 PM, Szymon Gatner wrote: On Monday, 6 April 2015 at 17:53:13 UTC, Steven Schveighoffer wrote: On 4/6/15 12:23 PM, Szymon Gatner wrote: Hi, I am surprised that this doesn't work: class Foo { void bar(string) {} } void bar(Foo foo, int i) { } auto foo = new Foo();

Re: Issue with free() for linked list implementation

2015-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/3/15 6:08 PM, Kitt wrote: On Friday, 3 April 2015 at 22:06:06 UTC, Namespace wrote: On Friday, 3 April 2015 at 22:02:13 UTC, Kitt wrote: Hello. I’m trying to write my own version of a list that doesn’t rely on the garbage collector. I’m working on a very bare bones implementation using

Re: Parameter is null by default. No value is given. Code says it is not null.

2015-04-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/9/15 9:32 AM, Adam D. Ruppe wrote: Don't use string == null, it is true for empty strings since null and an empty string are almost interchangable. I think this is not good advice. Comparing string to null is perfectly fine with ==. It's fine *because* null and empty strings are the same

Re: Associative array on the heap

2015-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 7:55 PM, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs, dynamic arrays or class objects, not int[string]'s Failed: [dmd, -v, -o-,

Re: GC Destruction Order

2015-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/19/15 4:16 PM, Namespace wrote: On Tuesday, 19 May 2015 at 20:02:07 UTC, rsw0x wrote: After dconf http://forum.dlang.org/thread/5554d763.1080...@dawg.eu#post-5554D763.1080308:40dawg.eu I thought the new releases would come faster. They should. This is an exception. Read the thread

Re: GC Destruction Order

2015-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/19/15 5:07 PM, bitwise wrote: On Tue, 19 May 2015 15:36:21 -0400, rsw0x anonym...@anonymous.com wrote: On Tuesday, 19 May 2015 at 18:37:31 UTC, bitwise wrote: On Tue, 19 May 2015 14:19:30 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Tuesday, 19 May 2015 at 18:15:06 UTC,

<    1   2   3   4   5   6   7   8   9   10   >