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 declaration

Re: Goto skipping declarations

2024-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
ome 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
iving 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
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
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 attributes

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
hin 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
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
ore 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
r 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-23 Thread Jonathan M Davis via Digitalmars-d-learn
e 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
oes 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

Re: static functions?

2024-03-11 Thread Jonathan M Davis via Digitalmars-d-learn
tml#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
> 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: The New DIP Process

2024-02-28 Thread Jonathan M Davis via Digitalmars-d-announce
On Wednesday, February 28, 2024 10:44:08 PM MST Brad Roberts via Digitalmars- d-announce wrote: > On 2/28/2024 7:34 PM, Jonathan M Davis via Digitalmars-d-announce wrote: > > On Wednesday, February 28, 2024 7:18:29 PM MST Mike Parker via > > Digitalmars-d-> > > announce

Re: The New DIP Process

2024-02-28 Thread Jonathan M Davis via Digitalmars-d-announce
On Wednesday, February 28, 2024 7:18:29 PM MST Mike Parker via Digitalmars-d- announce wrote: > On Wednesday, 28 February 2024 at 19:24:32 UTC, Jonathan M Davis > > wrote: > > I see that they're up on the NNTP server, and the web forum is > > hooked up to them, but the

Re: The New DIP Process

2024-02-28 Thread Jonathan M Davis via Digitalmars-d-announce
are these lists not going to have mailing lists like the others? - Jonathan M Davis

Re: Are exceptions caught in unittests?

2024-02-16 Thread Jonathan M Davis via Digitalmars-d-learn
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
way 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
d 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,

Re: The difference between the dates in years

2024-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
hereas 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
t 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
part(Date(2000, 2, 29), Date(2004, 2, 29)) == -4); assert(yearsApart(Date(2000, 2, 29), Date(2005, 2, 28)) == -4); } - Jonathan M Davis

Re: Preparing for the New DIP Process

2024-01-25 Thread Jonathan M Davis via Digitalmars-d-announce
On Thursday, January 25, 2024 8:03:41 AM MST Max Samukha via Digitalmars-d- announce wrote: > On Monday, 22 January 2024 at 23:28:40 UTC, Jonathan M Davis > > wrote: > > Of course, ultimately, different programmers have different > > preferences, and none of us are go

Re: User defined type and foreach

2024-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
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
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: Would this be a useful construct to add to D? auto for constructor call.

2024-01-23 Thread Jonathan M Davis via Digitalmars-d-announce
On Tuesday, January 23, 2024 4:11:00 AM MST ryuukk_ via Digitalmars-d-announce wrote: > On Tuesday, 23 January 2024 at 06:30:08 UTC, Jonathan M Davis > > wrote: > > That being said, I expect that it would be pretty easy to write > > a mixin to do something like that

Re: Would this be a useful construct to add to D? auto for constructor call.

2024-01-22 Thread Jonathan M Davis via Digitalmars-d-announce
n to do something like that if you really wanted to. Also, if you're simply looking to not have to name the type, you could do dataGrid = new typeof(datagrid)(15); - Jonathan M Davis

Re: Preparing for the New DIP Process

2024-01-22 Thread Jonathan M Davis via Digitalmars-d-announce
e happy about everything in any language. So, of course, there are going to be some folks who are unhappy with how D defines private, but it's not a feature that has actually been causing us problems, and it really doesn't make sense at this point to change how it works. - 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
us 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
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
ith 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 downsi

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

2024-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
me 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
at 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
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

Re: static array is not a range

2024-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
ut 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, while slicing static

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
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
ining 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
, 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.stdio might read in a file 4096 bytes at a time, wher

Re: pegged: non@safe semantic actions

2023-12-08 Thread Jonathan M Davis via Digitalmars-d-learn
. 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
acing '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
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
om/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
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
, 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
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 expect that wh

Re: How to do reflection on alias symbols

2023-11-16 Thread Jonathan M Davis via Digitalmars-d-learn
hen 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: DLF September 2023 Planning Update

2023-11-15 Thread Jonathan M Davis via Digitalmars-d-announce
On Wednesday, November 15, 2023 3:26:27 AM MST Sergey via Digitalmars-d- announce wrote: > On Wednesday, 15 November 2023 at 09:27:53 UTC, Jonathan M Davis > > wrote: > > On Tuesday, November 14, 2023 12:37:29 PM MST Sergey via > > > > Digitalmars-d- announce wrote: &

Re: DLF September 2023 Planning Update

2023-11-15 Thread Jonathan M Davis via Digitalmars-d-announce
take care of it rather than require that new code slap editions stuff everywhere), but there is a good reason for the approach that they're currently looking at taking. - Jonathan M Davis

Re: why remove octal literal support?

2023-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
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
t 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
ird 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
s 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
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
apper 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
y can 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
ve 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
ing 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
at 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-08 Thread Jonathan M Davis via Digitalmars-d-learn
any 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
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
e. 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
d 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
ange 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
xact 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 approach works extremely well. It just tends to take some getting us

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
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
a variety of items on my todo list. - Jonathan M Davis

Re: parallelism with delegate

2023-09-22 Thread Jonathan M Davis via Digitalmars-d-learn
um), 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: DConf '23 Talk Videos

2023-09-20 Thread Jonathan M Davis via Digitalmars-d-announce
> definitive answer tomorrow. If I'm lucky, a full internal > cleaning of the graphics card and some new thermal paste will > solve it. I'm usually not that lucky, though :-) Clearly, your computer is just sick of hearing about dconf and decided to go on strike. ;) - Jonathan M Davis

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

2023-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
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
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
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
ps://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
ou'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
t 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
ort std.traits : EnumMembers; enum Terminator { percent = '%', colon = ':', qmark = '?' } enum terminators = [EnumMembers!Terminator]; - Jonathan M Davis

Re: Why is GC.collect `pure`

2023-08-02 Thread Jonathan M Davis via Digitalmars-d-learn
rantees given by the language. So, while it does feel weird to allow pure functions to effectively mutate global state via the GC, when you consider how the language treats the GC's state and what the compiler actually does with pure, it should be pretty clear that treating these functions as pure shouldn't be a problem. - Jonathan M Davis

Re: How can overloads be distinguished on attributes alone?

2023-07-31 Thread Jonathan M Davis via Digitalmars-d-learn
So, while it may very well be possible to do something along the lines of what you're looking for, I strongly suspect that it's simply not worth it. - Jonathan M Davis

Re: AA vs __gshared

2023-07-27 Thread Jonathan M Davis via Digitalmars-d-learn
references escaping would be in the sections of code where you've cast away shared after locking the relevant mutex. So, similar to what happens with @safe and @trusted, using shared allows you to limit the code that you have to examine to find the problem. - Jonathan M Davis

Re: array index out of bound may not throw exception?

2023-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
you're using and whether the code in question is @safe. That will tell you whether a RangeError should be being thrown or not when an array index is out-of-bounds. - Jonathan M Davis

Re: Recommendation on plotting library

2023-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
hard to make predictions (especially about the > >> future), but I'd be interesting in your opinion on the matter. > > > > I'd be very surprised if dub added support for pre-compiled > > binaries - particularly since D isn't generally binary > > compatible acros

Re: Recommendation on plotting library

2023-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 21, 2023 1:03:47 AM MDT Chris Piker via Digitalmars-d-learn wrote: > On Friday, 21 July 2023 at 06:15:10 UTC, Jonathan M Davis wrote: > > On Thursday, July 20, 2023 10:57:22 PM MDT Chris Piker via > > Digitalmars-d-learn wrote: > > > > Regardless though

Re: Recommendation on plotting library

2023-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
ard library have largely replaced their Makefiles with D scripts. It's definitely worse if you want to write a script that needs to pull in dependencies that aren't part of the standard library, but if Phobos has what you need, it works quite well - and of course, you can always run other shell commands from within a D program. - Jonathan M Davis

Re: Pre-import version statements

2023-07-20 Thread Jonathan M Davis via Digitalmars-d-learn
continues to work. And if they need to stick to an older version of the compiler for some reason, they just use that version of the compiler. But writing code that explicitly depends on a particular version of the compiler is not something that many projects are likely to be doing. - Jonathan M Davis

  1   2   3   4   5   6   7   8   9   10   >