Re: assert

2024-09-10 Thread Jonathan M Davis via Digitalmars-d-learn
rogram is terminated instead of continuing in an invalid state. - Jonathan M Davis

Re: Problem with assertThrown

2024-09-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 9, 2024 6:40:07 PM MDT kookman via Digitalmars-d-learn wrote: > On Tuesday, 10 September 2024 at 00:27:43 UTC, Jonathan M Davis > > wrote: > > On Monday, September 9, 2024 5:46:18 PM MDT kookman via > > > > Digitalmars-d-learn wrote: > >>

Re: Problem with assertThrown

2024-09-09 Thread Jonathan M Davis via Digitalmars-d-learn
lance, it looks like the part of case 5 which explicitly catches the Exception and the part that uses assertThrown should behave the same, but your example doesn't actually compile (you didn't include a definition for base32Alphabet), so it's not actually possible to reproduce you

Re: Understanding the Behavior of i + ++i in D Language

2024-08-28 Thread Jonathan M Davis via Digitalmars-d-learn
ent, but it's arguably best practice to just avoid expressions that modify a variable while also evaluating that variable in another part of the expression. It makes the code clearer and avoids any order-of-evaluation issues which may exist in the language. - Jonathan M Davis

Re: create fixed length string of characters

2024-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2024 10:37:45 AM MDT Nick Treleaven via Digitalmars-d- learn wrote: > On Friday, 16 August 2024 at 16:30:09 UTC, Jonathan M Davis wrote: > > Whether the result of dup is then able to be implicitly > > converted to immutable based on whether the operation is p

Re: create fixed length string of characters

2024-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
sult is used. So, dup may very well work in this particular case, but in the general case, you really want to be using idup if you want immutable. And in this particular example, all it would take to make the result not immutable would be to use auto instead of string. - Jonathan M Davis

Re: copy must be const?!?

2024-07-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 26, 2024 2:17:21 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > On Thursday, 25 July 2024 at 13:07:03 UTC, Jonathan M Davis wrote: > > On Thursday, July 25, 2024 6:00:58 AM MDT Dom DiSc via > > > >> But a parameter given by value is ALWAYS a copy. >

Re: What is an rvalue constructor?

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
ors, an rvalue constructor would become a move constructor, though since it's not necessarily obvious that that's what it is, and such constructors already exist as normal constructors, there are some objections to making such a change. But of course, we'll have to see what ultimately happens with that. - Jonathan M Davis

Re: Prevent self-comparison without taking the address

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
dds via scope (since without the extra checks, you could easily take that address and pass it around, letting it escape the lifetime of the reference). - Jonathan M Davis

Re: copy must be const?!?

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
lates with a tail-const version similar to what we get with dynamic arrays, but that really only makes sense for certain types such as ranges. But either way, it would cause quite a few problems if IFTI started instantiating templates in general with mutable instead of the actual type that it's given, because it's extremely common that const and immutable types cannot be converted to mutable. - Jonathan M Davis

Re: copy must be const?!?

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
ert(is(typeof(arr) == const(int[]))); static assert(is(typeof(arr[]) == const(int)[])); So, if you have something like immutable string foo = "hello"; and you pass it to a templated function, the type will be treated as string, whereas with a user-defined type - or with any built-in types which aren't dynamic arrays - the templated function is instantiated with exactly the type that you pass it. - Jonathan M Davis

Re: Unexpected range assignment behaviour

2024-07-19 Thread Jonathan M Davis via Digitalmars-d-learn
u know enough to suspect that something along those lines might be the problem, I bet that most of us would not immediately come to that conclusion. It's just too subtle. And all to avoid typing a couple of characters. - Jonathan M Davis

Re: Why does this mixin fail to compile?

2024-07-02 Thread Jonathan M Davis via Digitalmars-d-learn
nd you could easily spend more time trying to optimize your build times than you would ever save by trying generate the string more efficiently, but it's your code. - Jonathan M Davis

Re: importC Error: undefined identifier `__atomic_thread_fence`

2024-06-23 Thread Jonathan M Davis via Digitalmars-d-learn
ully lead to the file being updated (and if you're feeling particularly motivated, you can always open a pull request - https://github.com/dlang/dmd/). - Jonathan M Davis

Re: Pointer to dlang spec for this alias construct?

2024-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
zeof; which would be equivalent to template sizeOf(T) { enum sizeOf = T.sizeof; } and they're used with function templates, e.g. T identity(T)(T value) { return value; } is equivalant to template identity(T) { T identity(T value) { return value; } } - Jonathan M Davis

Re: Socket and spawn()

2024-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 31, 2024 6:28:27 PM MDT Andy Valencia via Digitalmars-d-learn wrote: > On Friday, 31 May 2024 at 16:59:08 UTC, Jonathan M Davis wrote: > > Speaking as an old kernel engineer for the Sequent multiprocessor > product line, this is all very comfortable to me. I'm v

Re: Socket and spawn()

2024-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
ed. But if all you're doing is passing an object across threads, then it's pretty straightforward, since you just cast it to shared or immutable to be able to pass it across threads and then cast back to thread-local on the other side to use it as normal again (you just need to make sure that you don't leave a reference to the data on the original thread when you do that). - Jonathan M Davis

Re: Problem with clear on shared associative array?

2024-05-26 Thread Jonathan M Davis via Digitalmars-d-learn
ed AAs, because it has no way of guaranteeing that that's thread-safe. So, the solution is that you must explicitly removed shared temporarily to call clear when you know that it's thread-safe to do so. - Jonathan M Davis

Re: Goto skipping declarations

2024-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 3, 2024 2:38:31 PM MDT Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, May 3, 2024 1:15:16 PM MDT Ben Jones via Digitalmars-d-learn wrote: > > In general, you can't skip a declaration with goto, but it seems > > to be allowed if the declaratio

Re: Goto skipping declarations

2024-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
because of the label for some reason, and one or more of the checks that it's supposed to be doing is being missed. - Jonathan M Davis

Re: Why does Nullable implicitly casts when assigning a variable but not when returning from a function?

2024-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
ullable). E.g. auto a = nullable(3); allows you to not bother giving the explicit type of the Nullable at all. - Jonathan M Davis

Re: Using core/sys/posix/mqueue.d on FreeBSD

2024-04-06 Thread Jonathan M Davis via Digitalmars-d-learn
ndings if you want to use them now. - Jonathan M Davis

Re: Using core/sys/posix/mqueue.d on FreeBSD

2024-04-06 Thread Jonathan M Davis via Digitalmars-d-learn
them for Linux, so they got them added, but either no one else has needed the bindings, or no one else has needed them for anything other than Linux with glibc - or if they did, they didn't get them into druntime. - Jonathan M Davis

Re: impure

2024-04-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 5, 2024 3:11:42 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > On Sunday, 24 March 2024 at 09:16:20 UTC, Jonathan M Davis wrote: > > So, yes, you've run into a problem that it would be nice to > > have a better fix for, but even if we could negate attri

Re: How can I get an identifiquer of an usb or a harddisk? using C or Cpp or Dlang

2024-04-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 1, 2024 5:37:56 PM MDT dany via Digitalmars-d-learn wrote: > Actually I would get an ID's Usb That's going to depend on the operating system, and it's also going to depend on exactly what kind of ID you're looking for. - Jonathan M Davis

Re: How to make fields inaccessible (unreadable and unachangeable) outside of the structure?

2024-03-29 Thread Jonathan M Davis via Digitalmars-d-learn
worry about code within a module accidentally accessing other code within that module, then your module is probably too large anyway. So, if don't want code to be able to access any of the private members of your QueueNode type, that code will need to be in a separate module rather than in the same module as the QueueNode type. - Jonathan M Davis

Re: Setting up a final switch from a list

2024-03-28 Thread Jonathan M Davis via Digitalmars-d-learn
to do something like generate a switch statement from the list of enum members. https://dlang.org/phobos/std_traits.html#EnumMembers - Jonathan M Davis

Re: impure

2024-03-24 Thread Jonathan M Davis via Digitalmars-d-learn
t easy to miss the fact that a particular attribute applies to the code being changed. So, yes, you've run into a problem that it would be nice to have a better fix for, but even if we could negate attributes in general, there are good reasons to prefer to avoid mass-applying attributes. - Jonathan M Davis

Re: Mutate immutable inside shared static constructor

2024-03-23 Thread Jonathan M Davis via Digitalmars-d-learn
a value more than once. It should be initialized, and then it should be treated as illegal to ever assign to it - or to do anything else which would mutate it. So, clearly, the logic in static constructors with regards to non-mutable variables is overly simple at the moment. - Jonathan M Davis

Re: Mutability issue

2024-03-23 Thread Jonathan M Davis via Digitalmars-d-learn
atic assert(typeof(arr[]) == const(int)[]); For better or worse, arrays do that to avoid requiring that you explicitly slice them to pass them to range-based functions in the cases where you did something like declare a string to be immutable. But nothing like that happens with any other types, so if you pass a const Foo - or a const int - to a templated function, it's instantiated with that exact type. - Jonathan M Davis

Re: Implicit conversion of string to array of immutable ubytes

2024-03-22 Thread Jonathan M Davis via Digitalmars-d-learn
that they're used for the same thing at all. And having them be implicitly convertible could cause serious problems with overloading. If you want to do that conversion without a cast, then you can just use std.string.representation (which will do the cast internally). - Jonathan M Davis

Re: The std.file rename method fails in the docker environment.

2024-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 13, 2024 3:49:55 PM MDT zoujiaqing via Digitalmars-d-learn wrote: > On Wednesday, 13 March 2024 at 21:21:21 UTC, Jonathan M Davis > > wrote: > > On Wednesday, March 13, 2024 3:03:30 PM MDT zoujiaqing via > > > > Digitalmars-d-learn wrote: > >

Re: The std.file rename method fails in the docker environment.

2024-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
ile system and then does a copy and remove instead if moving within the file system doesn't work, but otherwise, you'll have to implement that yourself, which could be as simple as catching the any exceptions from move and then attempting to copy the file and then remove it if an exception was thrown. - Jonathan M Davis

Re: static functions?

2024-03-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 11, 2024 10:51:48 AM MDT Andy Valencia via Digitalmars-d- learn wrote: > On Monday, 11 March 2024 at 16:25:13 UTC, Jonathan M Davis wrote: > > ... > > But what exactly static means varies based on the context. > > Thank you for the list! But none of those

Re: static functions?

2024-03-11 Thread Jonathan M Davis via Digitalmars-d-learn
tributes: https://dlang.org/spec/attribute.html#visibility_attributes And specifically, to make a symbol only be visible inside a module, you mark it with private. - Jonathan M Davis

Re: chain of exceptions, next method

2024-03-06 Thread Jonathan M Davis via Digitalmars-d-learn
t; scope(failure)? If anything, I think that it's been decided that chained exceptions were a mistake. So, if things go in any direction with them, it's likely to be towards removing them, not doing more to support them. - Jonathan M Davis

Re: Are exceptions caught in unittests?

2024-02-16 Thread Jonathan M Davis via Digitalmars-d-learn
ing file = __FILE__, size_t line = __LINE__) { import core.exception : AssertError; try expression(); catch (T) return; static if (!is(immutable E == immutable noreturn)) throw new AssertError("assertThrown failed: No " ~ T.stringof ~ " was thrown" ~ (msg.length == 0 ? "." : ": ") ~ msg, file, line); } - Jonathan M Davis

Re: what was the problem with the old post blit operator already ?

2024-02-14 Thread Jonathan M Davis via Digitalmars-d-learn
ast away const or immutable to fix the copy. The only way to work properly with const or immutable is to construct the object with the changes in the first place rather than mutating the copy after the fact. - Jonathan M Davis

Re: std.string.assumeUTF() silently casting mutable to immutable?

2024-02-13 Thread Jonathan M Davis via Digitalmars-d-learn
char[] is @safe, so dmd should be taking that possibility into account, and it's apparently not. So, there's definitely a bug here, but it's a dmd bug. Its checks for whether it can safely change the constness of the return type apparently aren't sophisticated enough to catch this case. - Jonathan M Davis

Re: The difference between the dates in years

2024-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, February 10, 2024 7:31:47 PM MST Steven Schveighoffer via Digitalmars-d-learn wrote: > On Saturday, 10 February 2024 at 23:48:56 UTC, Jonathan M Davis > > wrote: > > If I understand correctly, he cares about how far into the > > month the dates > > are, whe

Re: The difference between the dates in years

2024-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
reas diffMonths ignores the smaller units, meaning that you get the same result no matter when in the month the dates are. So, 2000-05-10 - 1990-05-09 would give 10, whereas 2000-05-10 - 1990-05-30 would give 9. diffMonths / 12 would give 10 in both cases. - Jonathan M Davis

Re: The difference between the dates in years

2024-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
, there are edge cases where it definitely does the wrong thing (e.g. with regards to leap years or DST). And math around months is a prime area where it's difficult to get right in part because different people have different requirements depending on the actual problem that they're trying to solve. - Jonathan M Davis

Re: The difference between the dates in years

2024-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
== -3); assert(yearsApart(Date(2000, 2, 29), Date(2004, 2, 29)) == -4); assert(yearsApart(Date(2000, 2, 29), Date(2005, 2, 28)) == -4); } - Jonathan M Davis

Re: User defined type and foreach

2024-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
We would like to improve the situation with the next major version of Phobos so that the copy semantics of ranges are cleaner, and the range API will likely see a redesign to fix that issue, among others, but the current range API is as I've explained it to you, warts and all. - Jonathan M Davis

Re: Constructing arrays of structs

2024-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
tic arrays). As it is, you can probably only put the first dimension between the brackets, because other languages do that, and allowing it makes it easier to port code. Arguably though, for consistency, you should always put the dimensions between the parens when allocating a new dynamic array. - Jonathan M Davis

Re: User defined type and foreach

2024-01-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 19, 2024 3:49:29 AM MST Jim Balter via Digitalmars-d-learn wrote: > On Friday, 17 November 2017 at 17:55:30 UTC, Jonathan M Davis > > wrote: > > When you have > > > > foreach(e; range) > > > > it gets lowered to something like > >

Re: Datetime format?

2024-01-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 18, 2024 4:58:32 PM MST zoujiaqing via Digitalmars-d- learn wrote: > On Thursday, 18 January 2024 at 23:43:13 UTC, Jonathan M Davis > > wrote: > > On Thursday, January 18, 2024 4:26:42 PM MST zoujiaqing via > > > > Digitalmars-d- learn wrote: > &g

Re: Datetime format?

2024-01-18 Thread Jonathan M Davis via Digitalmars-d-learn
the various properties on SysTime and passing them to something like std.format's format to create a string, or there are several packages on https://code.dlang.org which have functions for doing custom date/time formatting. - Jonathan M Davis

Re: length's type.

2024-01-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 17, 2024 11:33:48 PM MST zjh via Digitalmars-d-learn wrote: > On Thursday, 18 January 2024 at 04:30:33 UTC, Jonathan M Davis > wrote: > but for a lot of code, using auto and size_t makes it > > > so that you don't need to use int, and it would be a big

Re: length's type.

2024-01-17 Thread Jonathan M Davis via Digitalmars-d-learn
because you'd just be using size_t, which would then be ulong on 64-bit systems. Obviously, when you do need to convert to int, then that can be annoying, but for a lot of code, using auto and size_t makes it so that you don't need to use int, and it would be a big problem in general if the language made length int. - Jonathan M Davis

Re: Understanding the Use of Nested Import and Selective Import in D

2024-01-17 Thread Jonathan M Davis via Digitalmars-d-learn
s run into. So, as is often the case, D's metaprogramming capabiltiies complicate the situation considerably with regards to tooling. - Jonathan M Davis

Re: Understanding the Use of Nested Import and Selective Import in D

2024-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 16, 2024 1:42:04 PM MST bomat via Digitalmars-d-learn wrote: > Wow, that was... exhaustive. Thanks for that. :) > One more question that I have, though... > > On Tuesday, 16 January 2024 at 19:05:43 UTC, Jonathan M Davis > > wrote: > > The downside of

Re: Understanding the Use of Nested Import and Selective Import in D

2024-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
ode easier, because they make it clear where the symbols are coming from. You do obviously need to be aware that you could run into problems with them depending on how you use them, but I don't even recall the last time that I had a problem due to a selective import. Regardless, obviously, you are going to have to decide what works for you, and that could change over time. Both features can definitely help with code encapsulation and with understanding where the symbols being used are actually coming from, but the cost-benefit analysis is likely to differ based on how you think and function. - Jonathan M Davis

Re: Would you recommend TDPL today?

2024-01-15 Thread Jonathan M Davis via Digitalmars-d-learn
s. I fully expect that there are things that you'd get out of TDPL that you wouldn't get from Ali's book, so there's definitely something to said for reading both, but again, whether that makes sense largely depends on whether you want to deal with figuring out which parts of TDPL are still valid. - Jonathan M Davis

Re: static array is not a range

2024-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
ctions, it will work directly with a static array (and should take it by ref to avoid copying) - at least so long as the function that it's given compiles properly. Personally, I'd just use a foreach loop and don't see much point in each at all, but looking at its implementation, it does look like the OP should be able to use it with static arrays in spite of the fact that they're not ranges - Jonathan M Davis

Re: static array is not a range

2024-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 9, 2024 4:13:23 AM MST Alexibu via Digitalmars-d-learn wrote: > On Tuesday, 9 January 2024 at 10:44:34 UTC, Jonathan M Davis > > wrote: > > How would it even be possible for a static array to be a range? > > It has a fixed length. For a type to work as a r

Re: static array is not a range

2024-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
be careful about the dynamic array (or any ranges which wrap it) escaping from the scope where the static array is, because if the static array goes out of scope and is destroyed, then any dynamic arrays referring to it will be referring to invalid memory, and you'll get undefined behavior. So, w

Re: Synchronisation help

2024-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 2, 2024 3:41:55 AM MST Anonymouse via Digitalmars-d-learn wrote: > On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: > > [...] > > Thank you. Yes, `Foo` is a class for the purposes of inheritance > -- I left that out of the example. > &g

Re: Synchronisation help

2024-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
have to deal with the locking primitives yourself as well as casting away shared to then operate on the AA while it's protected. It's a bug when you can do pretty much anything with a shared AA other than pass it around without casting away shared first. - Jonathan M Davis

Re: Synchronisation help

2024-01-01 Thread Jonathan M Davis via Digitalmars-d-learn
n. But if you want to use a class and use its built-in mutex with synchronized, that works too. Either way, it makes more sense to pass a shared object containing both the AA and the mutex around than to pass the AA around by itself given that the whole point of the mutex is to protect that AA. - Jonathan M Davis

Re: Checking path name

2023-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
directory, whether it exists, etc. - and of course, it has functions for reading in and writing to files. std.stdio also has some functions for reading from and writing to files, but the difference there is that it does it in pieces, whereas std.file reads and writes files as single units (e.g. std.std

Re: pegged: non@safe semantic actions

2023-12-08 Thread Jonathan M Davis via Digitalmars-d-learn
ng _deflayer from code that's marked with @safe, then you're going to get a compilation error. So, based on what I can see here, it looks like you need to be marking your functions with @safe where you can, and if any of your code is doing stuff that isn't guaranteed to be memory-safe (and thus can't be @safe), then you'll need to make sure that what it's doing is actually memory-safe (in spite of the fact that the compiler can't guarantee it) and mark it with @trusted to indicate that you've verified it, and then @safe code can call it. - Jonathan M Davis

Re: anonymous structs within structs

2023-12-05 Thread Jonathan M Davis via Digitalmars-d-learn
gt; Nor does replacing 'Dummy' with {} > > Suggestions? Normally, if you're not going to actually use the member variables, then there's no point in them even being there. However, if you need them there for alignment purposes, then you can just make them private. - Jonathan M Davis

Re: D Phobos Library Documentation: What is the Internal API for?

2023-11-27 Thread Jonathan M Davis via Digitalmars-d-learn
king on the compiler to more easily get an overview of the public symbols within those modules. But if you're not contributing to those projects, there really isn't any reason to see those modules. - Jonathan M Davis

Re: interface opEquals

2023-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
s. https://github.com/dlang/dmd/blob/master/druntime/src/object.d#L269 - Jonathan M Davis

Re: comparing with c strings

2023-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
r[] risks living longer than the char* that it's a slice of. But if all you're doing is comparing it against a D string, then presumably, you don't need to keep the char[] around, and you won't have to allocate a copy. https://dlang.org/phobos/std_string.html#.fromStringz - Jonathan M Davis

Re: How to write an interface but with different signatures

2023-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
all class-specific functions on it, but ideally, once you're dealing with an interface or base class, you just use it as that and don't need to do anything class-specific to it. So, if possible, it's generally better to figure out how to rework your code so that you don't need to set anything that's class-specific in the parts of the code which deal with the object through an interface or base class reference. - Jonathan M Davis

Re: How to do reflection on alias symbols

2023-11-17 Thread Jonathan M Davis via Digitalmars-d-learn
and that's been debated in the past), but it's unlikely to change at this point. So, if we were to add something to std.traits for them, it would probably be something more like isManifestConstant than isEnum. In spite of the keyword being used, they really aren't intended to be considered enums. - Jonathan M Davis

Re: How to do reflection on alias symbols

2023-11-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 16, 2023 6:04:43 PM MST Jonathan M Davis via Digitalmars-d-learn wrote: > I would suggest that you open up a bug report for it - > https://issues.dlang.org - and certainly, there's a good argument that what > you're seeing here is a bug. I fully expe

Re: How to do reflection on alias symbols

2023-11-16 Thread Jonathan M Davis via Digitalmars-d-learn
thus was not dealt with properly when the other bugs for visibility attributes on aliases were fixed however many years ago that was now. I very much doubt that what you're seeing is the intended behavior - or at least I fully expect that if Walter or one of the other compiler devs sees the issue, they will agree that what you're trying to do should work. - Jonathan M Davis

Re: why remove octal literal support?

2023-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
age. And in this case, not only does a template solve the problem quite easily, but it's solving a problem that only rarely needs to be solved these days. So, while some might prefer a language solution, this really isn't the sort of problem that D is likely to solve in the language at this point. - Jonathan M Davis

Re: DUB: Is it possible to set release as a default build for a dub package?

2023-11-04 Thread Jonathan M Davis via Digitalmars-d-learn
e, but that's going to be _very_ surprising to anyone else using your project and might cause issues if it's a project that other projects end up depending on. - Jonathan M Davis

Re: Convert String to Date and Add ±N Hours

2023-11-04 Thread Jonathan M Davis via Digitalmars-d-learn
ny format for converting from strings to Durations. There are third party libraries on code.dlang.org which support custom formatting for dates and times (e.g. https://code.dlang.org/packages/ae), but I'm not familiar enough with any of them to tell you how to solve your problem with them. That being said, since you seem to haves strings that are almost in the ISO extendend format, it should be pretty easy to get them to work with D's standard library. - Jonathan M Davis

Re: Keyword "package" prevents from importing a package module "package.d"

2023-11-03 Thread Jonathan M Davis via Digitalmars-d-learn
ly different. E.G. mymodule.d becomes foo/a.d and foo/b.d, with public imports in mymodule.d like you would have done in mymodule/package.d. You then either deprecate everything in mymodule.d so that folks will eventually change their code to use foo/a.d and foo/b.d directly, or you leave the code in the weird situation of everything being in the foo package, but existing code continues to import mymodule potentially forever. - Jonathan M Davis

Re: Keyword "package" prevents from importing a package module "package.d"

2023-11-02 Thread Jonathan M Davis via Digitalmars-d-learn
orts other modules in order to be able to import a single module and get several modules. Either way, personally, I don't think that that's something that should typically be done (with package.d or with any module name), but for whatever reason, some folks seem to love the idea. - Jonathan M Davis

Re: bigEndian in std.bitmanip

2023-10-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 31, 2023 8:23:28 AM MDT Salih Dincer via Digitalmars-d- learn wrote: > On Tuesday, 31 October 2023 at 10:24:56 UTC, Jonathan M Davis > > wrote: > > On Tuesday, October 31, 2023 4:09:53 AM MDT Salih Dincer via > > > > Digitalmars-d- learn wrote: >

Re: bigEndian in std.bitmanip

2023-10-31 Thread Jonathan M Davis via Digitalmars-d-learn
wrapper to use in your own code. - Jonathan M Davis

Re: dlang.org/spec/function.html#pure-functions example

2023-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 16, 2023 12:05:04 PM MDT Paul via Digitalmars-d-learn wrote: > On Thursday, 12 October 2023 at 21:20:44 UTC, Jonathan M Davis > > wrote: > > look like? > > > > Types can have static members. > > > > Basically what it comes down to is t

Re: dlang.org/spec/function.html#pure-functions example

2023-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 16, 2023 12:05:04 PM MDT Paul via Digitalmars-d-learn wrote: > On Thursday, 12 October 2023 at 21:20:44 UTC, Jonathan M Davis > > wrote: > > look like? > > > > Types can have static members. > > > > Basically what it comes down to is t

Re: dlang.org/spec/function.html#pure-functions example

2023-10-12 Thread Jonathan M Davis via Digitalmars-d-learn
an access via their arguments (be it by getting pointers from those arguments or calling other pure functions on them). - Jonathan M Davis

Re: The Power of Grammar Checkers: A Game-Changer for Writers!

2023-10-12 Thread Jonathan M Davis via Digitalmars-d-learn
to it just means that they have to remove your post too (which of course means that I'm adding to the problem as well, but at least now you know). - Jonathan M Davis

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-09 Thread Jonathan M Davis via Digitalmars-d-learn
#x27;t be a solution, since you can't call C functions during CTFE) rather than converting variables in general to string, then it shouldn't be hard to write a simple function that converts from an integer to a string. So, if that's all that you're looking to do, it shouldn't be hard to avoid Phobos. However, you're still going to need to implement it yourself. - Jonathan M Davis

Re: array setting : Whats going in here?

2023-10-08 Thread Jonathan M Davis via Digitalmars-d-learn
he assignment work and if it can statically see that the lengths of the arrays don't much. As such, I'm not sure that there's actually anything that the compiler could do here to catch the problem in the OP's case (at least not without doing code flow analysis, which isn't going to happen). - Jonathan M Davis

Re: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread Jonathan M Davis via Digitalmars-d-learn
. E.G. AliasSeq!(a, b) = doStuff(bar, 2.7); So, for many programmers, Tuple and tuple from std.typecons are good enough, and whether we ever get tuples added to the language will largely depend on whether anyone can come up with a proposal for them that convinces Walter and Atila that they're worth adding. Either way, the unpacking of dynamic arrays likely stands no chance whatsoever of ever being added, because it would require runtime checks to determine whether the unpacking was valid. - Jonathan M Davis

Re: array setting : Whats going in here?

2023-10-07 Thread Jonathan M Davis via Digitalmars-d-learn
r than assigning to foo. And then which elements are assigned to depends on how much of foo you slice, and how those elements are assigned to depends on the type of x. - Jonathan M Davis

Re: Type constraint

2023-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
compile-time one. https://dlang.org/spec/template.html#template_constraints https://dlang.org/spec/version.html#staticif https://dlang.org/spec/statement.html#if-statement http://ddili.org/ders/d.en/templates.html http://ddili.org/ders/d.en/cond_comp.html http://ddili.org/ders/d.en/if.html - Jonathan M Davis

Re: Type constraint

2023-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
mpiled in regardless (and potentially result in compiler errors if it doesn't work with the type that that the template is being instantiated with). So, you usually want to use static if with compile-time tests and not if. - Jonathan M Davis

Re: The difference between T[] opIndex() and T[] opSlice()

2023-10-01 Thread Jonathan M Davis via Digitalmars-d-learn
lice with two parameters for slicing the range or container, and then either opIndex or opSlice with no parameters to return a slice of the entire container (in which case, personally, I'd use opSlice, because semantically, that's what you're doing, but either should work IIRC). - Jonathan M Davis

Re: Straight Forward Arrays

2023-10-01 Thread Jonathan M Davis via Digitalmars-d-learn
ks in terms of performance. Of course, the exact performance characteristics are going to depend on what you're doing in your program, and whether the approach of D's dynamic arrays or C++'s std::vector is better depends on what your code is doing, but for most code, D's app

Re: Is it possible to create a kernel for an operating system in D?

2023-09-25 Thread Jonathan M Davis via Digitalmars-d-learn
ex.html#zachy The video isn't up yet though, since the videos are currently in the process of getting rendered and uploaded to youtube. https://forum.dlang.org/thread/rgevjorzaoeylhwii...@forum.dlang.org - Jonathan M Davis

Re: std.file: read, readText and UTF-8 decoding

2023-09-22 Thread Jonathan M Davis via Digitalmars-d-learn
but I have a variety of items on my todo list. - Jonathan M Davis

Re: parallelism with delegate

2023-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
e forum), but that's pretty much it, and even then, that doesn't remove it from the mailing list, because you can't get an e-mail back once it's been sent. So, once you send something to the forum, it's out there forever. - Jonathan M Davis

Re: std.file: read, readText and UTF-8 decoding

2023-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 21, 2023 9:29:17 AM MDT Uranuz via Digitalmars-d-learn wrote: > Hello! > I have some strange problem. I am trying to parse XML files and > extract some information from it. > I use library dxml for it by Jonathan M Davis. But I have a > probleme that I hav

Re: Weird floating point rounding - Bug or how to control it correctly

2023-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
you watch this video from dconf 2016 which discusses floating point values: https://www.youtube.com/watch?v=YEUAUnamQiA - Jonathan M Davis

Re: Is sizeof() available in D language?

2023-09-04 Thread Jonathan M Davis via Digitalmars-d-learn
compile-time value that gives the size of a type in bytes. In neither case does how it is calculated have any impact on the performance of the program. - Jonathan M Davis

Re: I don't understand betterC

2023-09-02 Thread Jonathan M Davis via Digitalmars-d-learn
evel module, object, you can only declare your own if you replace the default one, which you might do in some special situations, but it's not something that you would normally do, and you can never have both the normal object module and your own in the same program. - Jonathan M Davis

Re: Function to get the current hostname for both Windows and Posix

2023-08-27 Thread Jonathan M Davis via Digitalmars-d-learn
https://dlang.org/phobos/std_socket.html#.Socket.hostName - Jonathan M Davis

Re: Cool pattern or tragic?

2023-08-25 Thread Jonathan M Davis via Digitalmars-d-learn
- at least if you're not in an environment where everyone is expected to look at the code itself rather than at documentation. - Jonathan M Davis

Re: Mach status support

2023-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
e it is not full right now)? In general, system-specific bindings get added to druntime, because someone who needed them took the time to add them to the right place in druntime rather than there being an organized effort to add bindings to druntime. - Jonathan M Davis

Re: Setting up a final switch from a list

2023-08-02 Thread Jonathan M Davis via Digitalmars-d-learn
ey is on the all-values enum generating the array list. import std.traits : EnumMembers; enum Terminator { percent = '%', colon = ':', qmark = '?' } enum terminators = [EnumMembers!Terminator]; - Jonathan M Davis

  1   2   3   4   5   6   7   8   9   10   >