Re: `clear`ing a dynamic array

2015-10-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 25, 2015 09:34:25 Shriramana Sharma via Digitalmars-d-learn wrote: > rsw0x wrote: > > > use std.container.array > > Thanks all for all the recommendations. When would one use > std.array.appender with a built-in array vs std.container.array.Array? What > are the pros and cons

Re: Does D's GC release memory back to the OS?

2015-10-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 25, 2015 05:49:42 Richard White via Digitalmars-d-learn wrote: > Just wondering if D's GC release memory back to the OS? > The documentation for the GC.minimize > (http://dlang.org/phobos/core_memory.html#.GC.minimize) seems to > imply that it does, > but watching my OS's

Re: `clear`ing a dynamic array

2015-10-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 25, 2015 17:15:50 Shriramana Sharma via Digitalmars-d-learn wrote: > Jonathan M Davis via Digitalmars-d-learn wrote: > > > Appender really isn't intended to be used as a > > container - just as a way to make appending more efficient or to have an >

Re: `clear`ing a dynamic array

2015-10-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 25, 2015 16:23:14 Shriramana Sharma via Digitalmars-d-learn wrote: > Thanks all, for your replies. > > Jonathan M Davis via Digitalmars-d-learn wrote: > > > If you want a container rather than a dynamic array - especially if you're > > looking for

Re: splitter, compilation issue

2015-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 27, 2015 20:58:56 sigod via Digitalmars-d-learn wrote: > Here's simple code: > > import std.algorithm; > import std.array; > import std.file; > > void main(string[] args) > { > auto t = args[1].readText() > .splitter('\n') > .filter!(e =>

Re: std.variant.Algebraic, self referential types and delegate members

2015-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 08, 2015 10:31:11 Panke via Digitalmars-d-learn wrote: > import std.variant, std.stdio; > > --- > struct NodeTypeA(T) { T[] children; } > struct NodeTypeB(T) { Tree children; } > struct Leaf(T) { T delegate() dg; } > > alias Tree = Algebraic!(Leaf, NodeTypeA!This,

Re: Epoch time + msecs

2015-11-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 13, 2015 18:00:13 Handyman via Digitalmars-d-learn wrote: > How to get current time as a float (or a double or a real) as a > Unix epoch + milliseconds (e.g, 1447437383.465, or even > 1447437383.46512 with finer resolution)? I read > http://dlang.org/intro-to-datetime.html

Re: win32 from master: unicode functions by default?

2015-11-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 12, 2015 05:08:24 Mike Parker via Digitalmars-d-learn wrote: > On Thursday, 12 November 2015 at 04:58:42 UTC, Andre wrote: > > Hi, > > > > by using the win32 library from master, the functions aliases > > to the ansi windows functions (...A) instead of the unicode > >

Re: @property

2015-11-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 10, 2015 09:53:42 Gary Willoughby via Digitalmars-d-learn wrote: > On Monday, 9 November 2015 at 22:42:16 UTC, Fyodor Ustinov wrote: > > If this feature will be removed, it will be very lacking code, > > like: > > > > writeln = "Hello, world!"; > > > > :) > > WBR, > >

Re: Deprecation: module std.stream is deprecated

2015-11-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 08, 2015 14:41:05 Spacen Jasset via Digitalmars-d-learn wrote: > This looks the simplest solution at the moment: > > >> auto inputRange = File(__FILE__).byChunk(1024).joiner; > >> Foo foo = Foo(inputRange); > > But it doesn't seem efficient and strays off the

Re: Capturing __FILE__ and __LINE in a variadic templated function

2015-11-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 02, 2015 00:36:14 anonymous via Digitalmars-d-learn wrote: > On 01.11.2015 23:49, Adam D. Ruppe wrote: > > Yeah, just make the other args normal runtime instead of template: > > Or make it two nested templates: > > template show(T ...) > { > void show(string file =

Re: Efficiency of immutable vs mutable

2015-11-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 03, 2015 03:16:06 Andrew via Digitalmars-d-learn wrote: > I've written a short D program that involves many lookups into a > static array. When I make the array immutable the program runs > faster. This must mean that immutable is more than a restriction > on access, it must

Re: Capturing __FILE__ and __LINE in a variadic templated function

2015-11-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 03, 2015 07:35:40 Nordlöw via Digitalmars-d-learn wrote: > On Tuesday, 3 November 2015 at 06:14:14 UTC, Jonathan M Davis > wrote: > > You should pretty much never use __FILE__ or __LINE__ as > > template arguments unless you actually need to. The reason is > > that it will end

Re: Preventing implicit conversion

2015-11-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 04, 2015 21:22:02 ixid via Digitalmars-d-learn wrote: > On Wednesday, 4 November 2015 at 19:09:42 UTC, Maxim Fomin wrote: > > On Wednesday, 4 November 2015 at 14:27:49 UTC, ixid wrote: > >> Is there an elegant way of avoiding implicit conversion to int > >> when you're using

Re: Deprecation: module std.stream is deprecated

2015-11-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 07, 2015 12:10:05 Spacen Jasset via Digitalmars-d-learn wrote: > Deprecation: module std.stream is deprecated - It will be removed > from Phobos in October 2016. > > The std.stream module documentation doesn't give any clues as to > what an alternative might be. > > I have

Re: Deprecation: module std.stream is deprecated

2015-11-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 07, 2015 13:52:26 Spacen Jasset via Digitalmars-d-learn wrote: > Thanks Jonathan. I don't quite see what I want to do though. > > In order to abstract the file aspect of things away, and deal > with a stream of chars that could be from a file, or some some > other source

Re: Preventing implicit conversion

2015-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 05, 2015 09:33:39 ixid via Digitalmars-d-learn wrote: > In C++ I can add two shorts together without having to use a cast > to assign the result to one of the two shorts. It just seems > super clunky not to be able to do basic operations on basic types > without casts

Re: std.algorithm.startsWith only predicate

2015-10-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 18, 2015 17:48:18 Freddy via Digitalmars-d-learn wrote: > How do you call startsWith with only a predicate > --- > import std.algorithm; > import std.ascii; > > bool iden(string str) > { > return str.startsWith!(a => a.isAlpha || a == '_'); > } > --- startsWith doesn't

Re: Strange behavior of array

2015-10-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 16, 2015 04:39:57 Mike Parker via Digitalmars-d-learn wrote: > On Friday, 16 October 2015 at 03:01:12 UTC, VlasovRoman wrote: > > > Oh, thank you. Some strange solution. > > D doesn't have multidimensional built-in arrays, but rectangular > arrays. Think of it this way: > >

Re: Strange behavior of array

2015-10-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 16, 2015 08:37:09 Mike Parker via Digitalmars-d-learn wrote: > On Friday, 16 October 2015 at 07:25:16 UTC, Jonathan M Davis > wrote: > > > > > That does work currently, but there's talk off and on about > > deprecating the C syntax, so that may happen at some point, > > just

Re: StopWatch

2015-10-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 20, 2015 13:18:12 Shriramana Sharma via Digitalmars-d-learn wrote: > http://dlang.org/phobos/std_datetime.html#StopWatch shows the use of > TickDuration to measure the time elapsed, but > http://dlang.org/phobos/core_time.html#TickDuration says TickDuration is due > to be

Re: How to check whether an empty array variable is null?

2015-10-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 10, 2015 15:20:02 tcak via Digitalmars-d-learn wrote: > [code] > int[] list; > > list = new int[0]; > > std.stdio.writeln("Is Null ? ", (list is null)); > [/code] > > Result is "Is Null? true". > > Is this the correct behaviour? I would expect compiler to point > to an

Re: How to check whether an empty array variable is null?

2015-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 11, 2015 05:10:34 tcak via Digitalmars-d-learn wrote: > On Saturday, 10 October 2015 at 20:07:11 UTC, Jonathan M Davis > wrote: > > On Saturday, October 10, 2015 15:20:02 tcak via > > Digitalmars-d-learn wrote: > >> [code] > >> int[] list; > >> > >> list = new int[0]; > >> >

Re: SysTime bug or feature?

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 18:12:06 tchaloupka via Digitalmars-d-learn wrote: > This code: > > import std.stdio; > import std.datetime; > > void main() > { > SysTime t = SysTime.init; > writeln(t); > } > > results in segfault with dmd-2.068.2 > > Is it ok? It is by design, albeit

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 11:48:51 Marc Schütz via Digitalmars-d-learn wrote: > On Monday, 5 October 2015 at 10:30:02 UTC, Jonathan M Davis wrote: > > On Monday, October 05, 2015 09:07:34 Marc Schütz via > > Digitalmars-d-learn wrote: > >> I don't think math would be a problem. There are some

Re: Ternary if and ~ does not work quite well

2015-10-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 11, 2015 22:21:55 H. S. Teoh via Digitalmars-d-learn wrote: > It's best to parenthesize when mixing other operators with ?, because ? > has a pretty low precedence and may "steal" arguments from surrounding > operators that you don't intend. My suspicion is that what you wrote

Re: Struct toString works but not std.conv.to!string

2015-10-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 13, 2015 21:07:07 Nordlöw via Digitalmars-d-learn wrote: > I have defined a struct UTCOffset in > > https://github.com/nordlow/justd/blob/master/datetime_ex.d > > Everything works as desired except for > > import std.conv : to; > assert(UTCOffset(+14, 0).to!string ==

Re: Correctly implementing a bidirectional range on a linked list?

2015-07-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 06, 2015 21:58:30 anonymous via Digitalmars-d-learn wrote: Off topic: I think `@trusted:` is horrible. It's easy to forget that you're in a @trusted environment when editing things later. And even worse, you're trusting everything that's passed through template parameters.

Re: How to get the current Timezone

2015-08-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, August 29, 2015 05:25:33 rumbu via Digitalmars-d-learn wrote: On Friday, 28 August 2015 at 23:03:16 UTC, Jonathan M Davis wrote: I _really_ wish that Microsoft would just use the TZ database like everyone else... - Jonathan M Davis Starting with Windows 8.1, it does, but

Re: Can't chain reduce(seed, range)

2015-08-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 31, 2015 01:31:58 Yuxuan Shui via Digitalmars-d-learn wrote: Why is reduce defined as 'auto reduce(S, R)(S seed, R r)', instead of reduce(R r, S seed)? I can't chain it. Maybe provide both? The reasons why the seed is first are historical. It predates UFCS being added to the

Re: Array initialization with Struct templates

2015-08-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 31, 2015 04:57:05 WhatMeWorry via Digitalmars-d-learn wrote: This seemingly trivial array initialization has caused me hours of grief. enum Purpose { POSITIONAL, COLOR_ONLY, COLOR_AND_ALPHA, GENERIC_TRIPLE, GENERIC_QUAD } Purpose purpose; struct Chameleon(T, Purpose p)

Re: 2.068.0 std.process.executeShell how to set the shell?

2015-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 2 September 2015 at 01:26:23 UTC, Jonathan M Davis wrote: [snip] https://issues.dlang.org/show_bug.cgi?id=15000 - Jonathan M Davis

Re: Casting away immutability

2015-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 02, 2015 02:04:58 Sergei Degtiarev via Digitalmars-d-learn wrote: > I can't understand how cast coexist with immutability. Consider > the code: > immutable immutable(int)[4] buf; > auto x=buf[0]; > auto p=buf.ptr; > > auto i=cast(int[]) buf; > i[]=1; > >

Re: 2.068.0 std.process.executeShell how to set the shell?

2015-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 01, 2015 21:55:28 albatroz via Digitalmars-d-learn wrote: > Hi, since the upgrade to the latest version the function > executeShell (also the other functions), is not working has it > used to be, older versions of the compiler did not require any > change or setting the

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 01, 2015 20:05:18 drug via Digitalmars-d-learn wrote: > My case is I don't know what type user will be using, because I write a > library. What's the best way to process char[..] in this case? char[] should never be anything other than UTF-8. Similarly, wchar[] is UTF-16,

Re: Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 06, 2015 20:40:03 Gary Willoughby via Digitalmars-d-learn wrote: > Are there any Phobos functions to check file permissions on > Windows and Posix? For example, I want to check if a file is > readable and/or writable in a cross-platform fashion. Does anyone > have an example?

Re: Regression?

2015-09-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 08, 2015 07:12:50 FreeSlave via Digitalmars-d-learn wrote: > On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe > wrote: > > Fixed it by changing into: > > > > ``` > > import std.conv : text; > > string json = > >

Re: What is "FilterResult" type?

2015-09-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 08, 2015 11:08:57 Bahman Movaqar via Digitalmars-d-learn wrote: > However, I have made this a strict practice of mine to specify > the full signature of my public API. If your API returns ranges, that's general not only bad practice but arguably impossible. Most range-based

Re: 2.068.0 std.process.executeShell how to set the shell?

2015-09-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 02, 2015 15:28:35 albatroz via Digitalmars-d-learn wrote: > On Wednesday, 2 September 2015 at 01:46:18 UTC, Jonathan M Davis > wrote: > > On Wednesday, 2 September 2015 at 01:26:23 UTC, Jonathan M > > Davis wrote: > > [snip] > > > >

Re: Casting away immutability

2015-09-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 02, 2015 14:00:07 Sergei Degtiarev via Digitalmars-d-learn wrote: > On Wednesday, 2 September 2015 at 04:19:24 UTC, lobo wrote: > > No, I think your design is unsafe because you're throwing away > > type information and returning void[], then telling the > > compiler not

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 02, 2015 11:47:11 drug via Digitalmars-d-learn wrote: > On 02.09.2015 11:30, FreeSlave wrote: > >> I see, thanks. So I should always treat char[] as UTF in D itself, but > >> because I need to pass char[], wchar[] or dchar[] to a C library I > >> should treat it as not UTF

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 12, 2015 13:42:42 Prudence via Digitalmars-d-learn wrote: > On Saturday, 12 September 2015 at 06:23:12 UTC, Jonathan M Davis > wrote: > > On Friday, September 11, 2015 23:29:05 Laeeth Isharc via > > Digitalmars-d-learn wrote: > >> On Friday, 11 September 2015 at 21:58:28

Re: Why does reverse also flips my other dynamic array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 17:17:01 Ali Çehreli via Digitalmars-d-learn wrote: > On 09/13/2015 08:21 AM, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Saturday, September 12, 2015 14:59:23 Ali Çehreli via > Digitalmars-d-learn wrote: > >> On 09/12/2015 02:29

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 16:53:18 ponce via Digitalmars-d-learn wrote: > On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis > wrote: > > But the idea that your average D program is going to run into > > problems with the GC while using Phobos is just plain wrong. > > The folks who

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 16:58:21 Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis > wrote: > > the GC heavily. And the reality of the matter is that the vast > > majority of programs will have _no_ problems with using the GC

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 17:14:05 Prudence via Digitalmars-d-learn wrote: > On Sunday, 13 September 2015 at 16:58:22 UTC, Ola Fosheim Grøstad > wrote: > > On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis > > wrote: > >> the GC heavily. And the reality of the matter is that the

Re: shared array?

2015-09-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 14, 2015 01:12:02 Ola Fosheim Grostad via Digitalmars-d-learn wrote: > On Monday, 14 September 2015 at 00:41:28 UTC, Jonathan M Davis > wrote: > > Regardless, idiomatic D involves a lot more stack allocations > > than you often get even in C++, so GC usage tends to be low in

Re: shared array?

2015-09-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 14, 2015 14:19:30 Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Monday, 14 September 2015 at 13:56:16 UTC, Laeeth Isharc wrote: > The claim is correct: you need to follow every pointer that > through some indirection may lead to a pointer that may point > into the

Re: shared array?

2015-09-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 11, 2015 00:50:13 Adam D. Ruppe via Digitalmars-d-learn wrote: > On Friday, 11 September 2015 at 00:48:28 UTC, Prudence wrote: > > static Array!(bool delegate(int, WPARAM, LPARAM)) callbacks; > > Try just using a regular array instead of the library Array. > > > static bool

Re: shared array?

2015-09-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 11, 2015 23:29:05 Laeeth Isharc via Digitalmars-d-learn wrote: > On Friday, 11 September 2015 at 21:58:28 UTC, Adam D. Ruppe wrote: > > On Friday, 11 September 2015 at 21:48:14 UTC, Prudence wrote: > >> Oh really?!?! I thought slicing used the GC? Is this a recent > >>

Re: Huge output size for simple programs

2015-09-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 11, 2015 11:15:31 NX via Digitalmars-d-learn wrote: > I compile a simple hello world program in C and the results: > > hello_world.o -> 1.5 KB > hello_world (linux executable) -> 8.5 KB > > > Then I compile a simple hello world program in D (using DMD) and > the results: > >

Re: Threading Questions

2015-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 29, 2015 22:38:42 Johannes Pfau via Digitalmars-d-learn wrote: > Am Tue, 29 Sep 2015 15:10:58 -0400 > schrieb Steven Schveighoffer : > > > > > > 3) Why do I have to pass a "Mutex" to "Condition"? Why can't I just > > > pass an "Object"? > > > > An object

Re: How will std.allocator change how we program in D?

2015-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 02, 2015 23:54:15 Taylor Hillegeist via Digitalmars-d-learn wrote: > I do not come from a c++ background. but have looked at what > allocators do for c++. I know in D the standard for memory > management is garbage collection and if we want to manage it > ourselfs we have to do

Re: How to use std.range.interfaces in pure @safe code

2015-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 02, 2015 19:45:05 Freddy via Digitalmars-d-learn wrote: > How do I use http://dlang.org/phobos/std_range_interfaces.html in > pure @safe code? You don't. None of the functions in those interfaces are marked with @safe or pure. One of the problems with classes is that you're

Re: Posix termios

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 05:58:32 Alexander via Digitalmars-d-learn wrote: > Is it just me, or is not posix termios.h implemented in phobos? > (git), I am looking at core.sys.linux.termios but all I get there > is a few enums(B57600, B115200, etc..)? There's a core.sys.posix.termios and

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 04, 2015 16:13:47 skilion via Digitalmars-d-learn wrote: > Is this allowed by the language or it is a compiler bug ? > > void main() { > char[] a = "abc".dup; > ubyte[] b = [1, 2, 3]; > a = b; // cannot implicitly convert expression (b) of type > ubyte[] to char[]

Re: Threading Questions

2015-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 04, 2015 14:42:48 bitwise via Digitalmars-d-learn wrote: > Since D is moving towards a phobos with no GC, what will happen > to things that are classes like Condition and Mutex? Phobos and druntime will always use the GC for some things, and some things just plain need classes.

Re: How to do unittests

2015-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 02, 2015 10:22:38 Namal via Digitalmars-d-learn wrote: > So do I understand it right that it stops after the first failed > test? Is it possible to continue and get a list of all failed > tests? Once a unittest block within a module has a failure in it, then no more unittest

Re: problem with exceptions

2015-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 02, 2015 11:44:19 steven kladitis via Digitalmars-d-learn wrote: > C:\d\examples>pb2 > =>main's first line >=>makeOmelet's first line > =>prepareAll's first line >=>prepareEggs's first line > object.Exception@pb2.d(64): Cannot take -8 eggs from the fridge >

Re: Maximum number of threads

2015-09-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 24, 2015 08:55:22 Alex via Digitalmars-d-learn wrote: > This should be a not so long question to answer, I hope. > > I took an example from the "Programming in D" book, chapter > "Message Passing Concurrency", around page 550. The question of > interest was, how many threads

Re: question about multiple alias this

2015-09-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 24, 2015 13:04:20 steven kladitis via Digitalmars-d-learn wrote: > class A{ >int i; >bool b; >alias i this; >alias b this; > } > > void main() > { >auto a = new A; >int i = a; >bool b = a; > } > > --- this will not compile in dmd 2068.1. > ---

Re: foreach automoatic counter?

2015-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 21, 2015 15:38:38 French Football via Digitalmars-d-learn wrote: > Going through a book on coding in D, > http://ddili.org/ders/d.en/foreach.html , I find the following > very useful feature: > > When two names are specified in the names section [with a plain > array], they

Re: OS minimum version

2015-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 21, 2015 20:47:09 anonymous via Digitalmars-d-learn wrote: > On Monday 21 September 2015 14:47, ponce wrote: > > > 1. What is the minimum Windows version required by programs > > created with DMD? > > http://dlang.org/dmd-windows.html says: "Windows XP or later, 32 or 64 bit".

Re: Why are static arrays not ranges?

2015-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 21, 2015 20:46:51 Jack Stouffer via Digitalmars-d-learn wrote: > On Monday, 21 September 2015 at 20:39:55 UTC, Jesse Phillips > wrote: > > A static array has a constant length, so it is not possible to > > popFront on a static array. > > > > Making a dynamic array from it is

Re: Maximum number of threads

2015-09-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 24, 2015 12:38:39 Temtaime via Digitalmars-d-learn wrote: > Offtop: i think if number of threads > number of real cores, than > there's something wrong with your design. Maybe fibers suit > better ? That depends on what the threads are doing. If they're all CPU-intensive,

Re: How to get the current Timezone

2015-08-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 28, 2015 18:04:16 Adam D. Ruppe via Digitalmars-d-learn wrote: On Friday, 28 August 2015 at 17:59:06 UTC, WhatMeWorry wrote: Stupid question. If it always returns an empty string, why is it even there? It can return meaningful information in other subclasses; it is a

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 06, 2015 09:28:27 Marc Schütz via Digitalmars-d-learn wrote: > I see, this is a new problem introduced by `char + int = char`. > But at least the following could be disallowed without > introducing problems: > > int a = 'a'; > char b = 32; Sure, it would be nice, but

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 09:07:34 Marc Schütz via Digitalmars-d-learn wrote: > On Sunday, 4 October 2015 at 21:57:44 UTC, Jonathan M Davis wrote: > > On Sunday, October 04, 2015 16:13:47 skilion via > > Digitalmars-d-learn wrote: > >> Is this allowed by the language or it is a compiler bug ? >

Re: What is the postfix for min long value?

2015-10-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 06, 2015 15:16:12 tcak via Digitalmars-d-learn wrote: > While writing max ulong value, I added the "u" postfix. So > compiler accepted it as ulong value (That's my interpretation if > correct on compiler's side). > > writeln( 18_446_744_073_709_551_615u ); > > But when I try to

Re: utils.toBulkString is not accesible from utils

2015-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 02, 2015 06:33:32 Andre via Digitalmars-d-learn wrote: > Hi, > > for following coding there is an error during compilation: > >module utils; > >package string toBulkString(string s) >{ > import std.string: format; > return "$%s\r\n%s\r\n".format(s.length,

Re: Forward declaration issue

2015-12-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 04, 2015 08:12:05 Andre via Digitalmars-d-learn wrote: > Hi, > > I have a strange issue with following coding. > > void baz(); // forward declaration > > void foo() > { > void bar() > { > baz(); // (1) without f.d. syntax error > } > > void baz() > { >

Re: Are selective imports supposed to always be public?

2015-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 06, 2015 11:10:44 Mike Parker via Digitalmars-d-learn wrote: > On Sunday, 6 December 2015 at 10:31:58 UTC, tsbockman wrote: > > Why does this code compile? Shouldn't the `isIntegral` import > > be private to module `testB` unless I explicitly ask for it to > > be public? > > >

Re: Which type it better to use for array's indices?

2015-12-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 04, 2015 13:24:16 ref2401 via Digitalmars-d-learn wrote: > Which type it better to use for array's indices? > > float[] arr = new float[10]; > int i; > long j; > size_t k; > // which one is better arr[i], a[j]or arr[k] ? > > It seem like `size_t` suites well because 'is large

Re: question about the implementation of Variant

2016-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 04, 2016 07:30:50 aki via Digitalmars-d-learn wrote: > But wait, how does GC detect there still be a live reference to > the object Foo? > Because store is just a fix sized array of bytes. > ubyte[size] store; > GC cannot be aware of the reference, right? As I understand it,

Re: std.experimental.logger

2016-01-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 05, 2016 03:01:14 Mike via Digitalmars-d-learn wrote: > You are right, according to the docs your example should've > worked just fine. Tried it myself on DMD 2.069.2 and it doesn't > work either. You should raise an issue on github. We don't use the issue system on github. We

Re: RedBlackTree and myClass

2016-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 03, 2016 10:55:05 AntonSotov via Digitalmars-d-learn wrote: > import std.container.rbtree; > > class myClass { > string str; > } > > > int main() > { > auto tree = new RedBlackTree!myClass; > return 0; > } > > > Error: mutable method object.Object.opCmp is not

Re: version in enum

2016-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 09, 2016 13:32:49 Adam D. Ruppe via Digitalmars-d-learn wrote: > On Saturday, 9 January 2016 at 12:43:32 UTC, Øivind wrote: > > Why doesn't this work? Seems like it should: > > D defines version to only work on *complete* blocks. You're > trying to use it on a partial block

Re: C string to D without memory allocation?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 05:43:59 Jakob Ovrum via Digitalmars-d-learn wrote: > On Monday, 21 December 2015 at 05:41:31 UTC, Shriramana Sharma > wrote: > > Rikki Cattermole wrote: > > > >> string myCString = cast(string)ptr[0 .. strLen]; > > > > Thanks but does this require that one doesn't

Re: MonoTime longevity

2015-12-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 22, 2015 15:07:58 Steven Schveighoffer via Digitalmars-d-learn wrote: > MonoTime uses whatever precision is given to it by the OS. So if on your > OS, ticksPerSecond is 1e9, then your OS clock wraps at 18 hours as well. 1e9 ticks per second should still take over 293 years

Re: Scope of D packages

2015-12-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, December 19, 2015 17:09:49 Enamex via Digitalmars-d-learn wrote: > On Saturday, 19 December 2015 at 00:46:12 UTC, cym13 wrote: > > To be exact it doesn't need the sources, it needs the function > > signatures and type definitions so the equivalent of C header > > files. If you don't

Re: C string to D without memory allocation?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 18:39:32 Rikki Cattermole via Digitalmars-d-learn wrote: > size_t strLen = ...; > char* ptr = ...; > > string myCString = cast(string)ptr[0 .. strLen]; > > I can't remember if it will include the null terminator or not, but if > it does just decrease strLen by 1.

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 15:14:20 Shriramana Sharma via Digitalmars-d-learn wrote: > Hello. I want to define a template specialization using traits: > > import std.stdio, std.traits; > void func(T)(T t) { writeln(1); } > void func(T)(T t) if(isIntegral!T) { writeln(2); } > void main() > { >

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 21 December 2015 at 11:07:16 UTC, Jonathan M Davis wrote: For your example to work with template constraints, the most straightforward solution would be void func(T)(T t) if(!isIntegral!T) { writeln(1); } void func(T)(T t) if(isIntegral!T) { writeln(2); }

Re: Deimos recommendation still official?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 14:03:25 Shriramana Sharma via Digitalmars-d-learn wrote: > http://dlang.org/spec/interfaceToC.html refers one to Deimos > (https://github.com/D-Programming-Deimos) to look for existing bindings to C > libraries. Is this recommendation still valid? I ask because less

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 19:54:53 Shriramana Sharma via Digitalmars-d-learn wrote: > Thanks all for your replies. One question: > > Jonathan M Davis wrote: > > Alternatively, you can use static if, though you're only dealing > > with one template in that case. e.g. > > But if we wanted to

Re: Formatting dates

2015-11-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 28, 2015 18:10:49 Chris Wright via Digitalmars-d-learn wrote: > Is there a way to format a DateTime struct similar to strftime(3)? None > is documented, and none is immediately obvious in the source code. > > Or is the recommended way to convert a DateTime to a Unix

Re: DateTime.opBinary

2015-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 29, 2015 23:53:41 Chris Wright via Digitalmars-d-learn wrote: > Unfortunately, ddoc doesn't automatically cross-reference these for you, > which results in confusion. (As if it weren't confusing enough to have > everything wrapped in templates with filters rather than simply

Re: char[] == null

2015-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 18, 2015 22:15:19 anonymous via Digitalmars-d-learn wrote: > On 18.11.2015 22:02, rsw0x wrote: > > slices aren't arrays > > http://dlang.org/d-array-article.html > > The language reference/specification [1] uses the term "dynamic array" > for T[] types. Let's not enforce a

Re: opEquals default behaviour - poorly documented or am I missing something?

2015-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 17, 2015 20:25:30 user123ABCabc via Digitalmars-d-learn wrote: > On Tuesday, 17 November 2015 at 19:44:36 UTC, Ali Çehreli wrote: > > if (typeid(a) == typeid(b)) return a.opEquals(b); > > Wow this is terrible to compare two objects in D. The line I > quoted means that two

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 18:28:49 BBaz via Digitalmars-d-learn wrote: > this is only an error if bounds checking is not turned on. If you > compile your example with DMD option "-boundscheck=off", nothing > happens, and the slice will be equal (here) to a[3..$]; It's a logic error

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 22, 2015 03:19:54 Jon D via Digitalmars-d-learn wrote: > On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis > wrote: > > > > Honestly, arrays suck as output ranges. They don't get appended > > to; they get filled, and for better or worse, the documentation > > for

Re: `finally` is redundant?

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 22, 2015 02:00:46 Chris Wright via Digitalmars-d-learn wrote: > On Sat, 21 Nov 2015 16:10:45 -0800, Jonathan M Davis via > Digitalmars-d-learn wrote: > > > Getting rid of finally would mean > > reimplementing scope(exit) differently > > Well

Re: "final" as function parameter attribute?

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 15:14:31 Johan Engelen via Digitalmars-d-learn wrote: > On http://dlang.org/function.html, I read that "final" is a valid > attribute/storage class for function parameters: > > InOutX: > auto > TypeCtor > final <-- ?? > in > lazy > out

Re: `finally` is redundant?

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 11:15:22 Shriramana Sharma via Digitalmars-d-learn wrote: > The page http://dlang.org/exception-safe.html says: > > "It's try-finally that becomes redundant." > > IIUC this is because we have scope(exit). > > Does this mean that `finally` should eventually be

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 18:03:05 SimonN via Digitalmars-d-learn wrote: > string a = "hello"; > string b = a[3 .. 2]; > > I expect b to become an empty slice, because 3 is >= 2 already > after 0 increments, making the slice length 0. Instead, the code > throws a range violation. >

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 23:34:25 Jon D via Digitalmars-d-learn wrote: > Something I found confusing was the relationship between array > capacity and copy(). A short example: > > void main() > { > import std.algorithm: copy; > > auto a = new int[](3); > assert(a.length == 3);

Re: D equivalent of Python's try..else

2015-11-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 22, 2015 07:41:40 Mike Parker via Digitalmars-d-learn wrote: > On Saturday, 21 November 2015 at 13:57:01 UTC, Shriramana Sharma > wrote: > > > > Hmm – I forgot Python has `else` for `for` and `while` too. But > > it's a tad difficult to wrap one's mind around the meaning of > >

Re: Implicit conversion without alias this?

2016-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 03, 2016 16:12:50 maik klein via Digitalmars-d-learn wrote: > Any ideas? Well, alias this is the only way that D supports any kind of implicit conversions for user-defined types. So, if you want to have an implicit conversion for your type, you're going to have to figure out how

Re: Overriden method not detected ?

2016-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 03, 2016 13:27:41 chmike via Digitalmars-d-learn wrote: > On Friday, 3 June 2016 at 12:41:39 UTC, Jonathan M Davis wrote: > ... > > > On a side note, be warned that you almost certainly shouldn't > > be using __gshared like this. It's intended for interacting > > with C code not

Re: Overriden method not detected ?

2016-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 03, 2016 12:03:29 chmike via Digitalmars-d-learn wrote: > When trying to compile the following code I get a compilation > error > > > import std.stdio; > > class Info > { > final string name() { return nameImpl(); } > protected abstract string nameImpl(); > } > >

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