rappers like byDchar or byCodeUnit if you want much of anything involving
strings to be nothrow.
- Jonathan M Davis
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
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
>
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
>
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
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
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
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
for
equality (whereas using == with references would compare the objects
themselves for equality).
- Jonathan M Davis
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
'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
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
it slicing were required.
- Jonathan M Davis
rror when accessing the
static array anyway, then you could just forgo all checks entirely and let
druntime throw a RangeError.
- Jonathan M Davis
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
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
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
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
ose member function,
because the module-level function is shadowed by the member function.
- Jonathan M Davis
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
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
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
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
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
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
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
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
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
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++,
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
y be deprecated, though I wouldn't bet on that
actually happening.
- Jonathan M Davis
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
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 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
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
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
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
utting a dot in front of C function calls in general.
- Jonathan M Davis
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:
> >>
to a
mutable type.
- Jonathan M Davis
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
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
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
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
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
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
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
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
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
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
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
le, it would be
possible to do something like currTime().
- Jonathan M Davis
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
__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
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
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
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
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
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
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
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
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
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
>
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
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
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
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
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,
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
o pop off the elements that were taken.
- Jonathan M Davis
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
ed before the take range was consumed, or the take range would then
refer to invalid memory.
- Jonathan M Davis
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
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
>
> 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
itself), it risks breaking any
time that the build system is altered.
- Jonathan M Davis
to private members, then you need to put it in a separate module.
- Jonathan M Davis
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
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:
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
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
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
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
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
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
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
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
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
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
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
-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
ithout removing them from the BinaryHeap. As such, you can't print
them without removing them from the BinaryHeap.
- Jonathan M Davis
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
.
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
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
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
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
>
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
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
> >
> >
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
201 - 300 of 12832 matches
Mail list logo