Re: Why isn't skipOver(string, string) nothrow?

2019-10-22 Thread Jonathan M Davis via Digitalmars-d-learn
rappers like byDchar or byCodeUnit if you want much of anything involving strings to be nothrow. - Jonathan M Davis

Re: Some questions about GC

2019-10-18 Thread Jonathan M Davis via Digitalmars-d-learn
with dynamic arrays involving allocation), and if you truly don't want to use the GC for that stuff, it's probably going to be easier to require that your program not use the GC at all than to try to have it just manage cycles. Regardless, if you really want to go forward with something like you're proposing here, you'll probably need to get answers from one of the few GC experts around here. - Jonathan M Davis

Re: How Different Are Templates from Generics

2019-10-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 12, 2019 9:48:02 PM MDT jmh530 via Digitalmars-d-learn wrote: > On Saturday, 12 October 2019 at 21:44:57 UTC, Jonathan M Davis > > wrote: > > [snip] > > Thanks for the reply. > > As with most people, I don't write a lot of D code that uses >

Re: How Different Are Templates from Generics

2019-10-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 12, 2019 2:11:28 PM MDT jmh530 via Digitalmars-d-learn wrote: > On Friday, 11 October 2019 at 17:50:42 UTC, Jonathan M Davis > > wrote: > > [snip] > > A very thorough explanation! > > One follow-up question: would it be possible to mimic the >

Re: selective tests

2019-10-12 Thread Jonathan M Davis via Digitalmars-d-learn
up. Really, if you want to control which tests get run instead of simply always running them all, then you'll need to use an alternate test runner which supports that. There are a few test runners available on code.dlang.org, and I expect that at least one of them supports that (probably multiple do). - Jonathan M Davis

Re: _getmaxstdio / _setmaxstdio

2019-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
iate library. Given that the header is stdio.h, that would presumably be Microsoft's C runtime library, which probably means that you'd need to tell dmd to use Microsoft's C runtime and not dmc's C runtime. - Jonathan M Davis

Re: How Different Are Templates from Generics

2019-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
int would both be implementing the same interface, because in both cases, it would be ISomeInterface!int. SomeClass!int and SomeOtherClass!float would not be implementing the same interface, because it would be ISomeInterface!int and ISomeInterface!float, but ISomeInterface!int doesn't result in multiple instantiations even if it's used in different parts of the code. - Jonathan M Davis

Re: How Different Are Templates from Generics

2019-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
ates outright generate code, you can do a lot more with them than you could ever do with generics (e.g. making code differ based on the template arguments by using template constraints and/or static if). D's compile-time capabilities actually make it extremely powerful for generating code, and templates are a key part of that. - Jonathan M Davis

Re: C#'s 'is' equivalent in D

2019-10-10 Thread Jonathan M Davis via Digitalmars-d-learn
for equality (whereas using == with references would compare the objects themselves for equality). - Jonathan M Davis

Re: Dynamic Arrays as Stack and/or Queue

2019-10-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 8, 2019 2:42:22 PM MDT mipri via Digitalmars-d-learn wrote: > On Tuesday, 8 October 2019 at 10:48:45 UTC, Jonathan M Davis > > wrote: > > The result of this is that code like > > > > stack.popBack(); > > stack ~= foo; > > stack ~= bar

Re: Ranges to deal with corner cases and "random access"

2019-10-08 Thread Jonathan M Davis via Digitalmars-d-learn
's way too easy for a type to pass a template constraint thanks to alias this and then have trouble because it passed based on the implicit conversion, but the conversion wasn't forced in the code using the type. You can get some really subtle problems if the code converts to the alias in some cases but not in others. - Jonathan M Davis

Re: Dynamic Arrays as Stack and/or Queue

2019-10-08 Thread Jonathan M Davis via Digitalmars-d-learn
minimize the number of allocations while still avoiding constantly moving the elements around, but as with a stack, it's the sort of thing where you'd want to wrap the dynamic array in a struct or class to manage all of the logic required for pushing and popping elements instead of using a naked dynamic array. - Jonathan M Davis

Re: How does D distnguish managed pointers from raw pointers?

2019-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
it slicing were required. - Jonathan M Davis

Re: Using enforce or assert to check for fullness when appending to fixed length array container

2019-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
rror when accessing the static array anyway, then you could just forgo all checks entirely and let druntime throw a RangeError. - Jonathan M Davis

Re: Struct initialization has no effect or error?

2019-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
still error-prone, but at least you then eliminate the bugs where you initialize the wrong members and instead just get the ones where new members end up with the default value whether it's appropriate or not. - Jonathan M Davis

Re: C++ base constructor call vs. D's

2019-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
ints "D" class C { string foo() { return "C"; } this() { import std.stdio; writeln(foo()); } } class D : C { override string foo() { return "D"; } } void main() { auto d = new D; } whereas C++ equivalent would likely blow up in your face. - Jonathan M Davis

Re: Why dynamic array is InputRange but static array not.

2019-09-24 Thread Jonathan M Davis via Digitalmars-d-learn
then you need to slice it to get a dynamic array - though when you do that, make sure that the dynamic array is not around longer than the static array, because it's just a slice of the static array, and if the static array goes out of scope, then the dynamic array will then refer to invalid memory. - Jonathan M Davis

Re: wstring comparison is failing

2019-09-23 Thread Jonathan M Davis via Digitalmars-d-learn
oUTFz), and you have to strip it off when getting a string from C code (e.g. with fromStringz). Other than functions specifically designed to convert to and from C strings, D code is going to treat null terminators just like any other character, because D strings are not null-terminated. - Jonathan M Davis

Re: what is the mean that call function start with a dot.

2019-09-22 Thread Jonathan M Davis via Digitalmars-d-learn
ose member function, because the module-level function is shadowed by the member function. - Jonathan M Davis

Re: Looking for a Simple Doubly Linked List Implementation

2019-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
k with, whereas nodes in a linked list are normally private to the list, so it's easy to ensure that they're only ever on the heap even if they're structs). - Jonathan M Davis

Re: Why must a bidirectional range also be a forward range?

2019-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 20, 2019 7:08:03 AM MDT Joseph Rushton Wakeling via Digitalmars-d-learn wrote: > On Thursday, 19 September 2019 at 22:55:55 UTC, Jonathan M Davis > > wrote: > > For better or worse, ranges were more or less set up as a > > linear hierarchy, and it's un

Re: Avoid gratuitous closure allocations

2019-09-20 Thread Jonathan M Davis via Digitalmars-d-learn
ratice to use static structs in functions and avoid needing local context. Sometimes, it makes sense to do so, but in general, giving your struct access to the local scope in the function is going to result in closures being allocated when they could have easily been avoided. - Jonathan M Davis

Re: Why must a bidirectional range also be a forward range?

2019-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
ing them as more of an add-on capability (like length) rather than having the kind of hierarchy that we have now. I don't know if that's ultimately a good or a bad thing. - Jonathan M Davis

Re: Deprecation message sources

2019-09-17 Thread Jonathan M Davis via Digitalmars-d-learn
d to deprecate TickDuration (which is why it's not yet deprecated). Template constraints were triggering deprecation messages when I didn't think that they should be, but unfortunately, I didn't have time to narrow down what was going on so that I could create a proper bug report for it, and I haven't gotten back to it. - Jonathan M Davis

Re: Deprecation message sources

2019-09-17 Thread Jonathan M Davis via Digitalmars-d-learn
een problems in the past where template constraints triggered deprecation messages; last time I tried to deprecate TickDuration, I ran into a bunch of problems like that, which is why it hasn't been deprecated yet). - Jonathan M Davis

Re: Slicing upward

2019-09-14 Thread Jonathan M Davis via Digitalmars-d-learn
to stay valid as long as the "slices" were around (e.g. a static variable or on the heap), since if it's on the stack, and it goes out of scope, then your "slices" won't refer to valid memory anymore even if the memory that the dynamic array had referred to was still valid. It's the same problem you'd get if you had a dynamic array which was a slice of a static array which was on the stack, and the static array went out of scope. - Jonathan M Davis

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 8, 2019 12:12:53 PM MDT Exil via Digitalmars-d-learn wrote: > On Saturday, 7 September 2019 at 22:19:48 UTC, Jonathan M Davis > > wrote: > > On Saturday, September 7, 2019 3:40:58 PM MDT Exil via > > > > Digitalmars-d-learn wrote: > >> On

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 8, 2019 3:03:31 AM MDT Max Samukha via Digitalmars-d- learn wrote: > On Saturday, 7 September 2019 at 22:19:48 UTC, Jonathan M Davis > > wrote: > > On Saturday, September 7, 2019 3:40:58 PM MDT Exil via > > > > Digitalmars-d-learn wrote: > &g

Re: Mingling string and identifier namespaces in nested extern(C++) decls

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 7, 2019 2:18:40 PM MDT Jonathan M Davis via Digitalmars-d-learn wrote: > On Saturday, September 7, 2019 8:53:54 AM MDT Max Samukha via > Digitalmars-d- > learn wrote: > > extern(C++, "ns1") { > > > > extern(C++,

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 7, 2019 3:40:58 PM MDT Exil via Digitalmars-d-learn wrote: > On Saturday, 7 September 2019 at 17:22:07 UTC, Jonathan M Davis > > wrote: > > @safe: > > @system: > > > > then @system overrides @safe. > > Just to add onto this, you ca

Re: Mingling string and identifier namespaces in nested extern(C++) decls

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
y be deprecated, though I wouldn't bet on that actually happening. - Jonathan M Davis

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
IMHO. IIRC, this version of extern(C++) didn't go through the DIP process and was simply added via a PR. So, it wouldn't surprise me if the person who implemented it didn't even think about the extern(C++, "ns1"): extern(C++, "ns2"): case and didn't test for it properly. - Jonathan M Davis

Re: Old code no longer working on any DMD compilers

2019-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 5, 2019 11:59:30 PM MDT Jamie via Digitalmars-d-learn wrote: > On Friday, 6 September 2019 at 00:41:12 UTC, Jonathan M Davis > > wrote: > > On Thursday, September 5, 2019 6:24:07 PM MDT Jamie via > > > > Digitalmars-d-learn wrote: > >> /h

Re: Old code no longer working on any DMD compilers

2019-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
re able to compile your code before. A quick glance at the repo history shows that fmod has had that same implementation since 2012, so there should be no way that it was callable on any Linux system even 6 years ago, let alone 6 months ago. - Jonathan M Davis

Re: Quick question regarding dynamic array deletions

2019-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
arrays referring to that block of memory exist or that they won't be used again without first being given a new value. - Jonathan M Davis

Re: Is removing elements of AA in foreach loop safe?

2019-08-29 Thread Jonathan M Davis via Digitalmars-d-learn
t to remove elements in a loop, then you'll need to do something like put each key that you want to remove in a dynamic array while looping over the AA and then loop over the dynamic array to remove the elements from the AA. - Jonathan M Davis

Re: Question about generation of template functions

2019-08-28 Thread Jonathan M Davis via Digitalmars-d-learn
me foreach). If typeof(field) is ever not an A, then you can't pass the variable output to it, because output is an A. You need to pass it an lvalue that has the type typeof(field). I'm guessing that you meant to pass the member variables of output to serialize one by one and not output over and over again. - Jonathan M Davis

Re: .fflush() in stdio.d

2019-08-26 Thread Jonathan M Davis via Digitalmars-d-learn
utting a dot in front of C function calls in general. - Jonathan M Davis

Re: how to definition a non-const pointer that point a const var.

2019-08-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, August 24, 2019 12:48:33 AM MDT Max Haughton via Digitalmars-d- learn wrote: > On Saturday, 24 August 2019 at 05:03:43 UTC, Jonathan M Davis > > wrote: > > On Friday, August 23, 2019 10:14:56 PM MDT lili via > > > > Digitalmars-d-learn wrote: > >>

Re: how to definition a non-const pointer that point a const var.

2019-08-23 Thread Jonathan M Davis via Digitalmars-d-learn
to a mutable type. - Jonathan M Davis

Re: Template specialized functions creating runtime instructions?

2019-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
num result = factorial(5); There arguably isn't much point in using templated functions the way you are. It would be simpler to just write a function that calculated the result normally, and then if you want to have the result at compile time, you just call the function and use the result to give an enum its value. - Jonathan M Davis

Re: Can't add a const ubyte to a dynamic array of ubyte?

2019-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
nvException if the value of n doesn't fit in a ubyte). D does not allow implicit narrowing conversions (because there's no guarantee that the value will fit in the target type), so you can't assign a uint to a ubyte without an explicit conversion - and that includes appending to an array of ubytes. - Jonathan M Davis

Re: Is there any implementation of a 128bit integer?

2019-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
add them AFAIK. Phobos has std.bigint, which supports arbitrarily large integers, but there is no standard 128-bit integer solution at present. There may be such a solution on code.dlang.org, but I'm not aware of one. - Jonathan M Davis

Re: can DDOC generate files names including the full path ?

2019-08-18 Thread Jonathan M Davis via Digitalmars-d-learn
n generators. dub comes with ddox built in, or you can use Adam Ruppe's adrdox: https://github.com/adamdruppe/adrdox The built-in documentation generation can work quite well, but it's not quite as plug-and-play as would be nice and does tend to require that you put together a build script to generate your documentation instead of just being able to pass a single command and have it all just work. - Jonathan M Davis

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 8:14:52 AM MDT Newbie2019 via Digitalmars-d-learn wrote: > On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote: > > It is not possible to prevent moving in D as things currently > > stand. DIP 1014 will need to be implemented to either hook

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
does a move. It just allows you to hook into when a move takes place so that you can do stuff like adjust pointers, and presumably, if you @disable the function that hooks into the move, moving will then be disabled (though IIRC, that's not explicitly called out in DIP 1014; it's just what would naturally fall out from how @disable works). - Jonathan M Davis

Re: Cannot take the .keys of shared AA. Is this a regression in 2.087 or a feature?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 2:16:31 AM MDT Piotr Mitana via Digitalmars-d- learn wrote: > On Thursday, 15 August 2019 at 19:51:30 UTC, Jonathan M Davis > > wrote: > > Not being able to implicitly convert to const is a bit odd, but > > arguably, nothing should ever be called

Re: Cannot take the .keys of shared AA. Is this a regression in 2.087 or a feature?

2019-08-15 Thread Jonathan M Davis via Digitalmars-d-learn
ed). Because keys is not at all thread-safe, I'd strongly argue that it should not work on a shared AA, and if it does, that's a bug. - Jonathan M Davis

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
you're doing a lot of appending to them, because then it has to keep checking to see whether it can expand in place or has to allocate a new block of memory and copy the elements. In that respect, it's similar to C++'s std::vector. - Jonathan M Davis

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
uld be able to sort it. There might be a solution somewhere on code.dlang.org, but I don't know of any that I could point you to. Either way, if there's a solution floating around that you can use to sort a doubly-linked list in place, it's not an official one. - Jonathan M Davis

Re: What the abstrac final class mean?

2019-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
lves without specifying the full type. However, because _something_ has to be there to indicate that it's a declaration, auto is in the language so that the programmer has a way to indicate that it's a variable or function declaration. static by itself is plenty to indicate that a declaration is being provided. auto or void could be used, but they're not necessary. - Jonathan M Davis

Re: What the abstrac final class mean?

2019-08-12 Thread Jonathan M Davis via Digitalmars-d-learn
le, it would be possible to do something like currTime(). - Jonathan M Davis

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread Jonathan M Davis via Digitalmars-d-learn
ith class references. If I had code where whether casting to an interface or abstract class mattered, I'd want to redesign it so that that didn't matter. - Jonathan M Davis

Re: How to get name of my application (project)

2019-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
__MODULE__? > > If I understand the question correctly, you are looking for > std.file.thisExePath: > - http://dpldocs.info/experimental-docs/std.file.thisExePath.html > - https://dlang.org/phobos/std_file.html#thisExePath Also, the first element in the array passed to main is the n

Re: Can I remove an element from a global associative array from within a class destructor?

2019-08-02 Thread Jonathan M Davis via Digitalmars-d-learn
because there is no guarantee about the order that the objects are collected (otherwise, cyclical references would be a big problem), meaning that references in the finalizer could refer to objects that have already been destroyed and their memory freed. https://dlang.org/spec/class.html#destructors Basically, destructors/finalizers for anything on the GC heap are just for cleaning up non-GC-allocated resources. - Jonathan M Davis

Re: [OT] Re: Using Haskell for teaching [was: Help me decide D or C]

2019-08-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 2, 2019 11:05:13 AM MDT Russel Winder via Digitalmars-d- learn wrote: > On Fri, 2019-08-02 at 10:25 -0600, Jonathan M Davis via > Digitalmars-d-learn wrote: > > […] > > > My feeling is that functional languages are likely to be a very poor > > pl

Re: Help me decide D or C

2019-08-02 Thread Jonathan M Davis via Digitalmars-d-learn
to me. Imperative programming can already be a lot for beginners, but most people really don't think even vaguely in a functional manner. Even simple recursion tends to be a bit of a mind-bender for people at first. - Jonathan M Davis

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 29, 2019 3:11:45 PM MDT Matt via Digitalmars-d-learn wrote: > On Monday, 29 July 2019 at 19:38:34 UTC, Jonathan M Davis wrote: > > On Monday, July 29, 2019 11:32:58 AM MDT Matt via > > Digitalmars-d-learn wrote: > > > > > > > > Bec

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Jonathan M Davis via Digitalmars-d-learn
could have been marked as const or not. If you want empty to be const or not based on the range being wrapped, you'd need to use two separate function definitions (one const and one not) and use static if to choose which got compiled in based on whether it could be const or not with the range type that it's wrapping. - Jonathan M Davis

Re: Why in Phobos is empty() sometimes const and sometimes not

2019-07-29 Thread Jonathan M Davis via Digitalmars-d-learn
the range it's wrapping will work if that function is const, which essentially means duplicating a bunch of code for little to no benefit. - Jonathan M Davis

Re: There is anything like nodiscard attribute in D?

2019-07-29 Thread Jonathan M Davis via Digitalmars-d-learn
unction arguments (e.g. because they're pointers or ref), then ignoring the return value isn't necessarily a problem. However, that's the only time that D complains about a function's return value being ignored. - Jonathan M Davis

Re: Is it possible to disallow import for certain functions?

2019-07-27 Thread Jonathan M Davis via Digitalmars-d-learn
s. Pretty much the only time that I'd even consider it would be with version(unittest) so that the normal main isn't run when compiling and running unit tests. If code is going to be used across multiple projects (and thus need multiple mains), I'd have the shared code in a library, with the code including the different mains being completely separate - probably even in completely separate repos, since they'd be for different programs. - Jonathan M Davis

Re: Is betterC affect to compile time?

2019-07-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 25, 2019 6:13:38 PM MDT Mike Franklin via Digitalmars-d- learn wrote: > On Thursday, 25 July 2019 at 18:37:49 UTC, Jonathan M Davis wrote: > > There's probably at least one bug report on it, but as I > > understand it, it's not a bug in the sense that the >

Re: Is betterC affect to compile time?

2019-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
cted to handle such a case. It's an area where betterC should be improved upon, but it would be an enhancement, not a bug fix. - Jonathan M Davis

Re: Why is Throwable.TraceInfo.toString not @safe?

2019-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
n though they could be for _most_ derived classes, because they can't be pure for LocalTime), and there are cases where an attribute should be present but was simply never added. I don't know where TraceInfo sits, since I haven't dug into it. - Jonathan M Davis

Re: Milliseconds

2019-07-12 Thread Jonathan M Davis via Digitalmars-d-learn
ct lack of module-level documentation, and the package-level documentation is rather poor. I've been meaning to go back and redo that top-level documenation and generally go over the std.datetime documentation as a whole again, but I haven't gotten around to it yet. - Jonathan M Davis

Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Jonathan M Davis via Digitalmars-d-learn
n integral values from -127 to 127, odds are, you shouldn't be using byte. If you're doing something like breaking an integer into its 8-bit parts, then ubyte is what's appropriate, not byte. - Jonathan M Davis

Re: Is there something like a consuming take?

2019-07-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 7, 2019 12:36:42 PM MDT berni via Digitalmars-d-learn wrote: > On Sunday, 7 July 2019 at 09:01:53 UTC, Jonathan M Davis wrote: > > Without slicing, that's impossible without iterating over the > > elements multiple times. > > That's what I thought too,

Re: Is there something like a consuming take?

2019-07-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 6, 2019 12:58:52 PM MDT Adam D. Ruppe via Digitalmars-d- learn wrote: > On Saturday, 6 July 2019 at 18:17:26 UTC, Jonathan M Davis wrote: > > take _always_ consumes the range that it's given > > not if it hasSlicing. see > http://dpldocs.info/experi

Re: Is there something like a consuming take?

2019-07-07 Thread Jonathan M Davis via Digitalmars-d-learn
o pop off the elements that were taken. - Jonathan M Davis

Re: Is there something like a consuming take?

2019-07-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 6, 2019 12:17:26 PM MDT Jonathan M Davis via Digitalmars- d-learn wrote: > On Saturday, July 6, 2019 8:12:36 AM MDT berni via Digitalmars-d-learn > > wrote: > > Now it's getting weird. Meanwhile I encountered, that take() > > sometimes consumes and somet

Re: Is there something like a consuming take?

2019-07-06 Thread Jonathan M Davis via Digitalmars-d-learn
ed before the take range was consumed, or the take range would then refer to invalid memory. - Jonathan M Davis

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
it would have to be something that was guaranteed by the language's semantics regardless of whether any optimizations were being done. So, even if an advanced optimizer really did figure out how to avoid the GC allocations, that wouldn't help with @nogc. Rather, it would have to be built into the semantics

Re: Release Candidate [was: Re: Beta 2.087.0]

2019-07-04 Thread Jonathan M Davis via Digitalmars-d-announce
orted using it IIRC). I don't know what the current state of that is, but I recall there being a deprecation message about that behavior going away. So, if that behavior finally went away, then code could have compiled with the previous release but not the new one. - Jonathan M Davis

Re: D on ARM laptops?

2019-07-04 Thread Jonathan M Davis via Digitalmars-d-learn
> > LDC on FreeBSD working fine? It should work on FreeBSD 11. It almost certainly doesn't work on 12 because of bindings issues that still need to be resolved. Certainly, dmd does not work on FreeBSD 12, and ldc can't unless someone changed druntime specifically for ldc. - Jonathan M Davis

Re: Release D 2.087.0

2019-07-04 Thread Jonathan M Davis via Digitalmars-d-announce
itself), it risks breaking any time that the build system is altered. - Jonathan M Davis

Re: assert in unittest has access to private member?

2019-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
to private members, then you need to put it in a separate module. - Jonathan M Davis

Re: Illegal Filename after basic install and trying Hello World

2019-06-27 Thread Jonathan M Davis via Digitalmars-d-learn
Mac, but the windows may > be different) On Windows, it's sc.ini, whereas it's dmd.conf on every other platform. I have no clue why Windows is different from the rest. - Jonathan M Davis

Re: return scope ref outlives the scope of the argument

2019-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 25, 2019 6:32:35 AM MDT Eugene Wissner via Digitalmars-d- learn wrote: > On Tuesday, 25 June 2019 at 12:04:27 UTC, Jonathan M Davis wrote: > > On Tuesday, June 25, 2019 1:32:58 AM MDT Eugene Wissner via > > > > Digitalmars-d- learn wrote:

Re: return scope ref outlives the scope of the argument

2019-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
es look like the behavior changed with 2.086 even without -dip1000 being used, which probably has something to do with how the compiler was changed for DIP 1000, though it probably wasn't on purpose, since in theory, the behavior shouldn't have changed without -dip1000, but I don't know. - Jonathan M Davis

Re: return scope ref outlives the scope of the argument

2019-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
om func with a pointer to container, you definitely have an @safety problem, because that pointer would be invalid once func returned. - Jonathan M Davis

Re: What is iota function full name

2019-06-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 21, 2019 3:31:46 PM MDT KnightMare via Digitalmars-d-learn wrote: > On Friday, 21 June 2019 at 19:18:02 UTC, KnightMare wrote: > > On Friday, 21 June 2019 at 12:02:10 UTC, Jonathan M Davis wrote: > > > > auto goodName( ... ) { > > > > prag

Re: What is iota function full name

2019-06-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 21, 2019 5:10:03 AM MDT JN via Digitalmars-d-learn wrote: > On Friday, 21 June 2019 at 09:18:49 UTC, Jonathan M Davis wrote: > So, iota is > > > the name of the function, and it doesn't stand for anything. > > It's just the name of the Greek letter that was u

Re: What is iota function full name

2019-06-21 Thread Jonathan M Davis via Digitalmars-d-learn
stand for anything. It's just the name of the Greek letter that was used for a similar function in another language that most programmers these days have probably never heard of. - Jonathan M Davis

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
erneath the hood for that to work. It just won't require you to do it explicitly anymore, and the lifetime of the generated lvalue will be the same as any temporary. Ultimately, if you want a function to accept both rvalues and lvalues as efficiently as posible, just templatize it and use auto ref. - Jonathan M Davis

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 19, 2019 12:28:12 PM MDT XavierAP via Digitalmars-d-learn wrote: > On Wednesday, 19 June 2019 at 12:55:09 UTC, Jonathan M Davis > > wrote: > > Even in C++, using const ref is not as good a practice as it > > once was, because they added move constru

Re: Is it possible to escape a reserved keyword in Import/module?

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
o make it a legal identifier. https://dlang.org/dstyle.html#naming_keywords So, that's the way that it's handled in the standard library or any other code which follows the D style guide. e.g. The enum std.traits.FunctionAttribute has members such as pure_, nothrow_, and const_, since it can't use the actual keywords. - Jonathan M Davis

Re: What is the difference between extern(C++) extern(D)

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
ng a library) or for exposing symbols from those languages to D (e.g. that's what core.stdc.* does with C's standard library so that it can be used from D). https://dlang.org/spec/interfaceToC.html https://dlang.org/spec/cpp_interface.html - Jonathan M Davis

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
thin that part is const). As for the DIP, I'd suggest watching Andrei's recent dconf talk on the subject: https://www.youtube.com/watch?v=aRvu2JGGn6E=youtu.be - Jonathan M Davis

Re: Why after writeln the binaryHeap become empty?

2019-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
y Dlang Range are consumed by iterating > over them. I this design is strange. If you want an overview of ranges, you can watch this: https://www.youtube.com/watch?v=A8Btr8TPJ8c You can also read this: http://ddili.org/ders/d.en/ranges.html - Jonathan M Davis

Re: What's the difference between DIP25 and DIP1000?

2019-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
-dip1000 and still have their code interact with code that doesn't use it) and work towards making -dip1000 the default behavior, but I wouldn't expect such a change to happen soon. However, Walter is behind this strongly enough that I expect that it will _eventually_ become the default behavior. - Jonathan M Davis

Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
ithout removing them from the BinaryHeap. As such, you can't print them without removing them from the BinaryHeap. - Jonathan M Davis

Re: Specifying executable names in DUB

2019-06-17 Thread Jonathan M Davis via Digitalmars-d-learn
sed on what is being generated and what the platform is (e.g. adding lib to the front and either .a or .so to the end on *nix systems when a library is being generated). However, it's probably possible to use the postBuildCommands setting to run cp or mv or whatever to get the target name you want for that particular configuration. - Jonathan M Davis

Re: Suggest aesthetic way to Naming a module or a package with illegal lexical D lang keywords

2019-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
. Well, technically, per the style guide, the underscores would go at the end of the names, not the front, but that's only if you're trying to follow the style guide rather than be inspired by it. - Jonathan M Davis

Re: How to "Inherit" the attributes from a given callable argument?

2019-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
ich basically are templates) and > nested functions. It also now applies to auto return functions, though that's a more recent change. - Jonathan M Davis

Re: DIP 1013--The Deprecation Process--Formal Assessment

2019-06-12 Thread Jonathan M Davis via Digitalmars-d-announce
master/DIPs/accepted/DIP1013.md > > So what is the "version" in @@@DEPRECATED_[version]@@@ supposed > to be? That still seems to be ambiguous. How is it ambiguous? It says right in the same sentence that @@@DEPRECATED_[version]@@@ is mentioned. - Jonathan M Davis

Re: Why any! with map! is not working here

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 6, 2019 10:21:39 PM MDT rnd via Digitalmars-d-learn wrote: > On Thursday, 6 June 2019 at 21:32:11 UTC, Jonathan M Davis wrote: > > If any is not given a predicate, it defaults to just checking > > whether the element itself is true (requiring that the element >

Re: FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
rror so that they wouldn't have to first check whether they were passing a type that even made sense. It still seems like an odd decision though. Normally, you'd just require that an appropriate type be passed. - Jonathan M Davis

Re: Why any! with map! is not working here

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 6, 2019 5:50:36 AM MDT rnd via Digitalmars-d-learn wrote: > On Thursday, 6 June 2019 at 09:49:28 UTC, Jonathan M Davis wrote: > > So, to start, the any portion should be something more like > > > > any!pred(ss); > > > > or > > > >

Re: Why any! with map! is not working here

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
ascii.isASCII, which makes what you're testing for more explicit. And if you prefer UFCS, then bool isBinary(char[] ss){ return ss.byCodeUnit().any!isASCII(); } or bool isBinary(char[] ss){ return ss.byCodeUnit.any!isASCII; } - Jonathan M Davis

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