Re: betterC DLL in Windows

2023-02-06 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Feb 06, 2023 at 03:54:40PM +, bachmeier via Digitalmars-d-learn wrote: > On Sunday, 5 February 2023 at 08:48:34 UTC, Tamas wrote: [...] > > This is the specification for the D Programming Language. > > I've been bitten by that a few times over the years, though to be > honest, I'm

Re: WildCAD - a simple 2D drawing application

2023-01-30 Thread H. S. Teoh via Digitalmars-d-announce
On Tue, Jan 31, 2023 at 11:25:02AM +1300, Richard (Rikki) Andrew Cattermole via Digitalmars-d-announce wrote: > Like this? https://docs.webfreak.org/getting-started/first-steps/ Not bad! Looks much more promising than the original page for sure. Still ran into some issues though. The linked

Re: WildCAD - a simple 2D drawing application

2023-01-30 Thread H. S. Teoh via Digitalmars-d-announce
On Mon, Jan 30, 2023 at 08:39:33PM +, bachmeier via Digitalmars-d-announce wrote: > On Monday, 30 January 2023 at 04:40:48 UTC, Siarhei Siamashka wrote: > > On Monday, 30 January 2023 at 02:44:50 UTC, bachmeier wrote: > > > if you put your code in directories that match the modules you > > >

Re: Which TOML package, or SDLang?

2023-01-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 30, 2023 at 03:59:52PM +, Adam D Ruppe via Digitalmars-d-learn wrote: > On Monday, 30 January 2023 at 15:37:56 UTC, Guillaume Piolat wrote: > > Why not XML? :) It has comments, you can use backslashes too. > > no kidding, xml is an underrated format. XML is evil. Let me qualify

Re: D Language Foundation Monthly Meeting Summary for December 2022

2023-01-23 Thread H. S. Teoh via Digitalmars-d-announce
On Mon, Jan 23, 2023 at 08:43:03PM +, Adam D Ruppe via Digitalmars-d-announce wrote: > On Monday, 23 January 2023 at 20:06:46 UTC, H. S. Teoh wrote: > > There should be a tool for auto-generating JS wrappers, perhaps even > > HTML snippets, so that a user literally can just write: > > > >

Re: Where I download Digital Mars C Preprocessor sppn.exe?

2023-01-23 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 23, 2023 at 08:06:28PM +, Alain De Vos via Digitalmars-d-learn wrote: > Mixing D with C or C++ or Python is looking for problems. > Better write something in D. > And write something in C/C++/Python. > And have some form of communication between both. I don't know about Python,

Re: D Language Foundation Monthly Meeting Summary for December 2022

2023-01-23 Thread H. S. Teoh via Digitalmars-d-announce
On Sat, Jan 21, 2023 at 04:29:28AM +, Mike Parker via Digitalmars-d-announce wrote: [...] > __CTFE writeln__ > > Razvan next brought up [a PR to implement a `__ctfeWriteln` > built-in](https://github.com/dlang/dmd/pull/12412). It was currently > stalled and needed Walter's approval. Walter

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-01-20 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 20, 2023 at 01:32:22PM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 1/20/23 07:01, torhu wrote: > > > But why not have drawLine just be a free function? > > Exactly. > > If I'm not mistaken, and please teach me if I am wrong, they are > practically free functions in Java

Re: What is the 'Result' type even for?

2023-01-20 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 20, 2023 at 12:49:54PM +, Ruby The Roobster via Digitalmars-d-learn wrote: [...] > Thank you. I didn't know that there was such a property `.array`. It's not a property, it's a Phobos function from std.array. T -- INTEL = Only half of "intelligence".

Re: What is the 'Result' type even for?

2023-01-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 20, 2023 at 03:34:43AM +, Ruby The Roobster via Digitalmars-d-learn wrote: > On Friday, 20 January 2023 at 03:30:56 UTC, Steven Schveighoffer wrote: > > On 1/19/23 10:11 PM, Ruby The Roobster wrote: > > ... > > > > The point is to be a range over the original input, evaluated > >

Re: What is the 'Result' type even for?

2023-01-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 20, 2023 at 03:11:33AM +, Ruby The Roobster via Digitalmars-d-learn wrote: > Take this example: > > ```d > import std; > void main() > { > auto c = "a|b|c|d|e".splitter('|'); > c.writeln; > string[] e = ["a", "b", "c", "d", "e"]; > assert(c.equal(e)); >

Re: Coding Challenges - Dlang or Generic

2023-01-17 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 17, 2023 at 11:08:19PM +, Siarhei Siamashka via Digitalmars-d-learn wrote: > On Tuesday, 17 January 2023 at 21:50:06 UTC, matheus wrote: > > Question: Have you compared the timings between this way (With > > ranges) and a normal way (Without ranges)? > > If you are intensively

Re: ThePath - Convenient lib to deal with paths and files. (Alpha version)

2023-01-17 Thread H. S. Teoh via Digitalmars-d-announce
On Sun, Jan 15, 2023 at 01:53:51PM +, Dmytro Katyukha via Digitalmars-d-announce wrote: [...] > Also, this lib contains function > [createTempDirectory](https://github.com/katyukha/thepath/blob/master/source/thepath/utils.d), > that, i think, would be nice to have it in Phobos. Yes it would

Re: Creating a pointer/slice to a specific-size buffer? (Handing out a page/frame from a memory manager)

2023-01-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 13, 2023 at 08:31:17AM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 1/13/23 07:07, Gavin Ray wrote: > > > This is "valid" D I hope? > > Yes because static arrays are just elements side-by-side in memory. > You can cast any piece of memory to a static array provided the

Re: Why not allow elementwise operations on tuples?

2023-01-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 13, 2023 at 02:22:34PM +, Sergei Nosov via Digitalmars-d-learn wrote: > Hey, everyone! > > I was wondering if there's a strong reason behind not implementing > elementwise operations on tuples? > > Say, I've decided to store 2d points in a `Tuple!(int, int)`. It would > be

Re: append - too many files

2023-01-10 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 11, 2023 at 02:15:13AM +, Joel via Digitalmars-d-learn wrote: > I get this error after a while (seems append doesn't close the file > each time): > std.file.FileException@std/file.d(836): history.txt: Too many open files > > ```d > auto jm_addToHistory(T...)(T args) { >

Re: Coding Challenges - Dlang or Generic

2023-01-09 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 10, 2023 at 03:18:54AM +, matheus via Digitalmars-d-learn wrote: > On Tuesday, 10 January 2023 at 01:22:33 UTC, H. S. Teoh wrote: > > ... > > > > Here's a challenge. Given an input year, for example, "2023", > > write a program that outputs (for the corresponding year): > > ... >

Re: Coding Challenges - Dlang or Generic

2023-01-09 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 10, 2023 at 12:17:18AM +, Paul via Digitalmars-d-learn wrote: > Greetings Dlang-ers > I was wondering if anyone knew of any coding challenges available > where the input and output are specified and its left to the > programmer to find a solution? Here's a challenge. Given an

Re: Good News: Almost all druntime supported on arsd webassembly

2023-01-06 Thread H. S. Teoh via Digitalmars-d-announce
On Fri, Jan 06, 2023 at 12:52:43PM +, Hipreme via Digitalmars-d-announce wrote: > Hello people. I have tried working again with adam's wasm minimal > runtime, and yesterday I was able to make a great progress on it. [...] > All those tests are currently passing. That means we almost got all >

Re: Safer Linux Kernel Modules Using the D Programming Language

2023-01-06 Thread H. S. Teoh via Digitalmars-d-announce
On Fri, Jan 06, 2023 at 04:07:12AM +, areYouSureAboutThat via Digitalmars-d-announce wrote: [...] > btw. Linus one said, more or less, that one reason he likes C so much, is > because when he is typing it, he can visualise what assembly will be > produced (i.e. his mind is always intune with

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 05, 2023 at 10:46:07PM +, thebluepandabear via Digitalmars-d-learn wrote: > On Thursday, 5 January 2023 at 17:36:55 UTC, H. S. Teoh wrote: [...] > > ```D > > foreach (BoardSize boardSize; arr) { > > Button button = new Button(); > > button.text = format("%sx%s",

Re: GC interaction with malloc/free

2023-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 05, 2023 at 08:18:42PM +, DLearner via Digitalmars-d-learn wrote: > On Thursday, 5 January 2023 at 19:54:01 UTC, H. S. Teoh wrote: [...] > > core.stdc.stdlib.{malloc,free} *is* the exact same malloc/free that > > C uses, it has nothing to do with the GC. The allocated memory is >

Re: GC interaction with malloc/free

2023-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 05, 2023 at 07:49:38PM +, DLearner via Digitalmars-d-learn wrote: > Suppose there is a D main program (not marked anywhere with @nogc), > that _both_ > > A: Calls one or more C functions that themselves call malloc/free; and > also > B: Calls one or more D functions that

Re: Is there a way to enforce UFCS?

2023-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 05, 2023 at 02:32:17PM +, Dom DiSc via Digitalmars-d-learn wrote: [...] > I think this is really another usecase for @property: we should forbid the > function call syntax for them (so one needs to use them like a variable). [...] > Properties are not functions. If you want a

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 05, 2023 at 11:55:33AM +, thebluepandabear via Digitalmars-d-learn wrote: [...] > ```D > foreach (BoardSize boardSize; arr) { > Button button = new Button(); > button.text = format("%sx%s", boardSize[0], boardSize[1]); > button.onButtonClick = { >

Re: Address of a class object

2023-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 05, 2023 at 06:32:47AM +, areYouSureAboutThat via Digitalmars-d-learn wrote: [...] > Second, to be sure your getting the correct results, it would be nice > if there was a 'category of type' in std.traits for: > > isAllocatedOnStack > isAllocatedOnHeap > > As it is, your just

Re: Address of a class object

2023-01-04 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 04, 2023 at 01:20:12PM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 1/4/23 12:02, Steven Schveighoffer wrote: > > On 1/4/23 2:27 PM, Ali Çehreli wrote: > > >> I put the objects into a 2-length > >> static array but the difference was still 0x20. (?) > > > > Are you putting

Re: Address of a class object

2023-01-04 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 04, 2023 at 09:51:05AM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 1/3/23 20:01, Paul wrote: > > > Size Alignment Type > > = > >17 8 MyClass > > > > MyClassObj1 MyClassObj2 > > 27727202000 27727202020 > > ``` > > If my

Re: Breaking news: std.uni changes!

2023-01-02 Thread H. S. Teoh via Digitalmars-d-announce
On Tue, Jan 03, 2023 at 05:13:53PM +1300, Richard (Rikki) Andrew Cattermole via Digitalmars-d-announce wrote: > On 03/01/2023 10:24 AM, Dukc wrote: > > Other things coming to mind: Bidirectional grapheme iteration, > > Word break and line break algorithms, lazy normalisation. Indeed, > > lots of

Re: Compile time vs run time -- what is the difference?

2022-12-31 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jan 01, 2023 at 02:18:23AM +, Salih Dincer via Digitalmars-d-learn wrote: > On Sunday, 1 January 2023 at 01:20:02 UTC, Ali Çehreli wrote: > > On 12/31/22 16:42, H. S. Teoh wrote: > > > > - runtime: The D runtime. > > Sometimes I see runtime facilities used as compile time and I'm

Re: Address of a class object

2022-12-31 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jan 01, 2023 at 12:35:40AM +, Paul via Digitalmars-d-learn wrote: > Hello. Thanks for any assistance. > > Can I acquire the address of a class object, not a class variable > (i.e. the instantiations of the class) but the object definition > itself? > > ```d > class MyClass {char c}

Re: Compile time vs run time -- what is the difference?

2022-12-31 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 28, 2022 at 02:31:45AM +, thebluepandabear via Digitalmars-d-learn wrote: > I am reading through the free book on learning D by Ali Çehreli and I > am having difficulties understanding the difference between compile > time execution and run time execution in D language. It's very

Re: Confusion about `Random`

2022-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 23, 2022 at 03:21:24PM +, jwatson-CO-edu via Digitalmars-d-learn wrote: > On Friday, 23 December 2022 at 00:00:06 UTC, H. S. Teoh wrote: [...] > > My personal guess is that you forgot a `ref` somewhere when you pass > > the RNG to a function. Given that due to historical accident

Re: Confusion about `Random`

2022-12-22 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 22, 2022 at 08:17:56PM +, jwatson-CO-edu via Digitalmars-d-learn wrote: > On Thursday, 22 December 2022 at 17:33:48 UTC, Paul Backus wrote: > > So, as far as I can tell, there is nothing wrong with your code, and > > the random number generator is working as intended. > > > >

Re: Does 'ref' turn into a pointer during compile time?

2022-12-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 22, 2022 at 12:43:28AM +, thebluepandabear via Digitalmars-d-learn wrote: > Say you have the following function that takes in a `ref` parameter: > > ```D > void modify(ref int num) { > num += 5; > } > ``` > > Does the compiler turn that into the code below? > > ```D > void

Re: text based file formats

2022-12-20 Thread H. S. Teoh via Digitalmars-d-announce
On Tue, Dec 20, 2022 at 07:46:36PM +, John Colvin via Digitalmars-d-announce wrote: [...] > > There's also my little experimental csv parser that was designed to > > be as fast as possible: > > > > https://github.com/quickfur/fastcsv > > > > However it can only handle input that fits in

Re: text based file formats

2022-12-19 Thread H. S. Teoh via Digitalmars-d-announce
On Mon, Dec 19, 2022 at 04:16:57PM -0800, Walter Bright via Digitalmars-d-announce wrote: > On 12/19/2022 4:35 AM, Adam D Ruppe wrote: > > On Monday, 19 December 2022 at 09:55:47 UTC, Walter Bright wrote: > > > Curious why CSV isn't in the list. > > > > Maybe std.csv is already good enough? > >

Re: How is this code invalid?

2022-12-17 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Dec 17, 2022 at 02:36:10AM +, thebluepandabear via Digitalmars-d-learn wrote: [...] > Thanks, I've tried to mark it with `@safe` and it did give me a > warning. > > I was also wondering, why is this code valid? > > ```D > int[] numbersForLaterUse; > > @safe void foo(int[] numbers)

Re: How is this code invalid?

2022-12-16 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 16, 2022 at 05:39:08PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > If you really want to see what could possibly have gone wrong, try > this version of the code: [...] > The results will likely differ depending on your OS and specific > environment; but

Re: How is this code invalid?

2022-12-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Dec 17, 2022 at 12:23:32AM +, thebluepandabear via Digitalmars-d-learn wrote: [...] > ```D > int[] numbersForLaterUse; > > void foo(int[] numbers...) { >numbersForLaterUse = numbers; > } > > struct S { > string[] namesForLaterUse; > > void foo(string[] names...) { >

Re: Gotcha with photos' documentation

2022-12-09 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 09, 2022 at 12:51:27PM +0100, Christian Köstlin via Digitalmars-d-learn wrote: > On 09.12.22 02:27, H. S. Teoh wrote: [...] > > https://github.com/dlang/phobos/pull/8646 [...] > Thanks a lot ... > that was fast. It only took a minute to fix. :-D > Is there also an implementation

Re: Gotcha with photos' documentation

2022-12-08 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 08, 2022 at 05:21:52PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > I'll see if I can reword this to be more explicit. [...] https://github.com/dlang/phobos/pull/8646 T -- Don't modify spaghetti code unless you can eat the consequences.

Re: Gotcha with photos' documentation

2022-12-08 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 08, 2022 at 09:15:45PM +0100, Christian Köstlin via Digitalmars-d-learn wrote: > Recently I stumbled upon a small issue in dlang's docs. > I wanted to look up uniq in std.algorithm. Started from > https://dlang.org/phobos/std_algorithm.html and clicked uniq, no > problem, all good.

Re: printf, writeln, writefln

2022-12-06 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 06, 2022 at 11:07:32PM +, johannes via Digitalmars-d-learn wrote: > //-- the result should be f.i. "the sun is shining" > //-- sqlite3_column_text returns a constant char* a \0 delimited c-string > printf("%s\n",sqlite3_column_text(res, i)); > writeln(sqlite3_column_text(res, i));

Re: How ptr arithmitic works??? It doesn't make any sense....

2022-12-04 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 04, 2022 at 04:33:35PM +, rempas via Digitalmars-d-learn wrote: > First a little bit of theory. A pointer just points to a memory > address which is a number. So when I add "10" to this pointer, it will > point ten bytes after the place it was pointing to, right? This is true only

Re: Why can't D store all UTF-8 code units in char type? (not really understanding explanation)

2022-12-02 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 02, 2022 at 11:47:30PM +, thebluepandabear via Digitalmars-d-learn wrote: > On Friday, 2 December 2022 at 23:44:28 UTC, thebluepandabear wrote: > > > :-D > > > > > > (Exercise for the reader: what's the Hausdorff dimension of the > > > set of strings over Unicode space? :-P) > >

Re: Why can't D store all UTF-8 code units in char type? (not really understanding explanation)

2022-12-02 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 02, 2022 at 02:32:47PM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 12/2/22 13:44, rikki cattermole wrote: > > > Yeah you're right, its code unit not code point. > > This proves yet again how badly chosen those names are. I must look it > up every time before using one or

Re: Why can't D store all UTF-8 code units in char type? (not really understanding explanation)

2022-12-02 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 02, 2022 at 09:18:44PM +, thebluepandabear via Digitalmars-d-learn wrote: > Hello (noob question), > > I am reading a book about D by Ali, and he talks about the different > char types: char, wchar, and dchar. He says that char stores a UTF-8 > code unit, wchar stores a UTF-16

Re: Is there a formula for overflow?

2022-11-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 30, 2022 at 03:07:44AM +, thebluepandabear via Digitalmars-d-learn wrote: > I am reading through Ali's book about D, and he gives the following > examples for an overflow: [...] > The result overflows and is 1705032704. > > Also for the second example, it overflows and comes up

Re: How often I should be using const? Is it useless/overrated?

2022-11-18 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 18, 2022 at 11:51:42AM +, thebluepandabear via Digitalmars-d-learn wrote: A question I have been thinking about whilst using D is how often I should be using const. You should use it as often as you need to use it, and no more. If you don't need to use it, don't use it.

Re: Need Advice: Union or Variant?

2022-11-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 17, 2022 at 10:16:04PM +, jwatson-CO-edu via Digitalmars-d-learn wrote: > On Thursday, 17 November 2022 at 21:05:43 UTC, H. S. Teoh wrote: [...] > > struct Atom { > > F_Type kind; > > union { // anonymous union > > Atom*

Re: Need Advice: Union or Variant?

2022-11-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 17, 2022 at 08:54:46PM +, jwatson-CO-edu via Digitalmars-d-learn wrote: [...] > ```d > enum F_Type{ > CONS, // Cons pair > STRN, // String/Symbol > NMBR, // Number > EROR, // Error object > BOOL, // Boolean value > FUNC, // Function > } > > struct Atom{ >

Re: Can we ease WASM in D ?

2022-11-16 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 16, 2022 at 10:51:31PM +, bioinfornatics via Digitalmars-d-learn wrote: > Dear community, > > I look some day ago to the D wasm page: > -> https://wiki.dlang.org/Generating_WebAssembly_with_LDC > > And since then I ask myself can we at compile time convert a D code > to an

Re: Removing an element from an array

2022-11-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 10, 2022 at 11:26:45PM +, Alexander Zhirov via Digitalmars-d-learn wrote: > I have an array of self-written class `A`. I'm sorry for my tactlessness, > but I'm confused about the modules. How do I correctly find a specific > object `fragment` inside the array and delete it? I

Re: dirEntries removes entire branches of empty directories

2022-11-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 10, 2022 at 07:07:33PM +, Imperatorn via Digitalmars-d-learn wrote: > On Thursday, 10 November 2022 at 16:34:53 UTC, Ali Çehreli wrote: > > On 11/9/22 11:30, Vladimir Panteleev wrote: > > > On Wednesday, 9 November 2022 at 19:05:58 UTC, Ali Çehreli > > > wrote: > > >> Running the

Re: Make IN Dlang

2022-11-04 Thread H. S. Teoh via Digitalmars-d-learn
Happened to stumble across this today, which I thought is a relevant, if sadly humorous, take on build systems: https://pozorvlak.dreamwidth.org/174323.html T -- ASCII stupid question, getty stupid ANSI.

Re: Makefiles and dub

2022-11-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 04, 2022 at 11:19:17PM +, Anonymouse via Digitalmars-d-learn wrote: > [#20699](https://issues.dlang.org/show_bug.cgi?id=20699) must be > non-trivial to fix, so I'm exploring makefiles. If possible I'd like > to keep dub for dependency management though, just not for actual >

Re: Hipreme's #4 Tip of the day - Don't use package.d

2022-11-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 04, 2022 at 07:34:58PM +, jmh530 via Digitalmars-d-learn wrote: > On Friday, 4 November 2022 at 19:17:04 UTC, Adam D Ruppe wrote: > > On Friday, 4 November 2022 at 19:10:33 UTC, jmh530 wrote: > > > If you don't plan to use private(package_name), then I don't know > > > what the

Re: D Language Foundation October 2022 Quarterly Meeting Summary

2022-11-04 Thread H. S. Teoh via Digitalmars-d-announce
On Fri, Nov 04, 2022 at 03:57:05PM +, Bastiaan Veelo via Digitalmars-d-announce wrote: > On Wednesday, 2 November 2022 at 18:20:42 UTC, H. S. Teoh wrote: > > On Wed, Nov 02, 2022 at 06:11:12PM +, M. M. via > > Digitalmars-d-announce wrote: > > > Thank you to Martin Nowak for all his as

Re: Make IN Dlang

2022-11-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 02, 2022 at 09:16:22PM +0100, Christian Köstlin via Digitalmars-d-learn wrote: > On 02.11.22 20:16, H. S. Teoh wrote: [...] > > IMO, the ideal situation is a hybrid situation: the underlying build > > mechanism should be purely declarative, because otherwise the > > complexity just

Re: Unit testing a function returning void

2022-11-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 03, 2022 at 08:51:52AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 11/3/22 03:00, Bruno Pagis wrote: > > >void print() { > > writeln("array = ", this.array); > >} > > Similar to Paul Backus's program but I would try to avoid the file system > for unit tests

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 03, 2022 at 04:41:14AM +, Siarhei Siamashka via Digitalmars-d-learn wrote: [...] > ```D > @safe: > import std.stdio; > class A { > void foo() { writeln("foo"); } > } > void main() { > auto a1 = new A; > a1.foo(); // prints "foo" > A a2; > a2.foo(); // Segmentation fault

Re: Make IN Dlang

2022-11-02 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 02, 2022 at 03:08:36PM +, JN via Digitalmars-d-learn wrote: > On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: > > sh("touch %s".format(t.name)); > > One of the problems of many Make-like tools is that they offer lots of > freedom, especially

Re: D Language Foundation October 2022 Quarterly Meeting Summary

2022-11-02 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, Nov 02, 2022 at 06:11:12PM +, M. M. via Digitalmars-d-announce wrote: > On Wednesday, 2 November 2022 at 04:42:06 UTC, Mike Parker wrote: > > The D Language Foundation's October 2022 meeting was a quarterly, > > meaning that several industry representatives attended. It took > > place

Re: druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Nov 01, 2022 at 10:37:57AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 11/1/22 10:27, H. S. Teoh wrote: > > > Maybe try running Digger to reduce the code for you? > > Did you mean dustmite, which is accessible as 'dub dustmite > ' but I haven't used it. Oh yes, sorry, I

Re: druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Nov 01, 2022 at 05:19:56PM +, mw via Digitalmars-d-learn wrote: > My program received signal SIGSEGV, Segmentation fault. > > Its simplified structure looks like this: > > ``` > void foo() { > ... > writeln("done"); // saw this got printed! > } > > int main() { > foo(); >

Re: how to benchmark pure functions?

2022-10-27 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 27, 2022 at 06:20:10PM +, Imperatorn via Digitalmars-d-learn wrote: > On Thursday, 27 October 2022 at 17:17:01 UTC, ab wrote: > > Hi, > > > > when trying to compare different implementations of the optimized > > builds of a pure function using benchmark from > >

Re: Importing modules under DUB on Windows

2022-10-26 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via Digitalmars-d-learn wrote: > Hi > > Never used DUB before. > Wanted to use a function stored in a module outside the main source. > > Main source has `import ;` > > Put a line into the JSON: `"importPaths": "C:\\Users\\..."` pointing > to

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 26, 2022 at 12:16:55AM +, Salih Dincer via Digitalmars-d-learn wrote: [...] > I've known D for more than 10 years, but the topic we're talking about > still seems strange to me. The explanations given are not enough for > me, I'm sorry. > > Can anyone tell me what happens when I

Re: Supporting foreach (k, v; T.init) for a user-defined (container) type

2022-10-24 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Oct 24, 2022 at 09:26:14PM +, Per Nordlöw via Digitalmars-d-learn wrote: > What property of a container (type) `T` enables iteration as > > ```d > foreach (k, v; T.init) > { > ... > } > ``` > > ? I thought it sufficed to define `T.byKeyValue` but its presence seem > to have no

Re: Design question regarding saving changes in the original array and/or returning a new set

2022-10-23 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Oct 23, 2022 at 01:32:44PM +, matheus via Digitalmars-d-learn wrote: > Hi, > > I have a design question and I'd like to hear some advice. Let's say > that I want to create a method to sort an array: > > arr.sort(asc); > > I think usually this would usually return a new set of

Re: [Help Needed] - Debugging compilation time

2022-10-21 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 21, 2022 at 04:32:17PM +, Hipreme via Digitalmars-d-learn wrote: > Hey guys, I have been complaining a lot of time right now from D > compilation speed at least for my project. > > I have: > - Underused CTFE > - Underused Templates > - Avoided importing standard libraries > -

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 19, 2022 at 01:15:37AM +, Adam D Ruppe via Digitalmars-d-learn wrote: > On Wednesday, 19 October 2022 at 00:57:31 UTC, H. S. Teoh wrote: > > Has it really been implemented? I tested the latest git master, the > > following code doesn't compile: > > it only applies to types, not

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 15, 2022 at 12:47:02AM +, Mike Parker via Digitalmars-d-learn wrote: > On Friday, 14 October 2022 at 22:17:52 UTC, H. S. Teoh wrote: > > > Given that this particular trap crops up regularly, perhaps some > > sort of warning ought to be added. Once the @nodiscard DIP is > >

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 14, 2022 at 09:51:54PM +, WhatMeWorry via Digitalmars-d-learn wrote: > > I lost about a half an hour troubleshooting some code of mine which as it > turned out to be resolved with just one line. > > > // paths.remove(i); // compiles fine but does nothing > > paths =

Re: Convert int to dchar

2022-10-05 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 05, 2022 at 04:57:57PM +, Paul via Digitalmars-d-learn wrote: >I'm sure I'm making this more difficult than it needs to be. I'm > trying to convert an integer to a dchar. The solution below works but > seems like overkill. > > dstring dstrValue = to!dstring(5); >

Re: rotate left an array

2022-10-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Oct 03, 2022 at 05:38:25PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > Good catch but I think what we want is a copy of the front element, at > least for InputRanges (.save does not work for File.byLine :/). One of the things we need to settle in Phobos v2 is what to do

Re: How is it possible that countUntil() generates a jump-table when the hayStack is a compile time array?

2022-10-01 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 01, 2022 at 01:20:08PM +, realhet via Digitalmars-d-learn wrote: > Hello, > > I just wanted to optimize a byte -> index lookup, by using a 256 > element table instead of using [1, 2, 3].countUntil(x) and I was > amazed what I've found. > My solution lookup[x] was not faster at

Re: How to workaround on this (bug?)

2022-09-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Sep 17, 2022 at 12:19:16AM +, frame via Digitalmars-d-learn wrote: > On Friday, 16 September 2022 at 23:06:35 UTC, H. S. Teoh wrote: > > > Basically, if you pass something to .fun by value, then that value > > must be destroyed by .fun once it's ready to return. So if the > > value

Re: How to workaround on this (bug?)

2022-09-16 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 16, 2022 at 10:43:43PM +, frame via Digitalmars-d-learn wrote: > ```d > import std.variant; > > // error: destructor `std.variant.VariantN!32LU.VariantN.~this` is not > `nothrow` > void fun(Variant v) nothrow > { > > } > > void main() > { >fun(Variant()); > } > ``` > > A

Re: Function attribute best practices

2022-09-12 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 12, 2022 at 02:29:58PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > If your intent is to *enforce* pure functions only, then that's what > you do. If your intent instead is to ensure that given proper > parameters, the function will be pure, then the answer is

Re: Function attribute best practices

2022-09-12 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 12, 2022 at 10:08:29AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > What I meant was > > - if I put 'pure' etc. on my templatized code, > > - and then tested with a 'pure' unittest, > > I wouldn't know that the gratuitous use of my 'pure' on the member > function was

Re: Function attribute best practices

2022-09-12 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 12, 2022 at 09:14:42AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > struct Foo(R) { > R r; > int i; > > bool empty() @nogc nothrow pure @safe scope { > return r.empty; > } > > auto front() @nogc nothrow pure @safe scope { > return

Re: import `Class` is used as a type

2022-09-10 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Sep 10, 2022 at 04:59:50PM +, Injeckt via Digitalmars-d-learn wrote: > I'm trying use classes in my project, but when i'm try inherit class, > I get error: > > Error: import `Server.Console` is used as a type [...] Don't name the module the same thing as the class. Rename it

Re: How include header file?

2022-09-07 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote: > I need to include this Ws2tcpip.h header file to my project. How can I > do this? It's all because I need inet_ntop function from this header > file. If that's the only function you need, you can just copy the

Re: GCC 12.2 Released (D v2.100.1)

2022-08-19 Thread H. S. Teoh via Digitalmars-d-announce
On Fri, Aug 19, 2022 at 11:36:09AM +, Iain Buclaw via Digitalmars-d-announce wrote: > Hi, > > GCC version 12.2 has been released. [...] > - Updated the D front-end from v2.100.0-rc1 to v2.100.1. [...] :-O TOTAL AWESOMENESS!!! Now GDC is officially up-to-date with the latest version of the

Re: How to use exceptions

2022-08-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 12, 2022 at 12:12:13AM +, Adam D Ruppe via Digitalmars-d-learn wrote: > On Thursday, 11 August 2022 at 23:50:58 UTC, H. S. Teoh wrote: > > I think the OP's idea is somewhat different: adding contextual > > information to a propagating exception that the throwing code may > > not

Re: How to use exceptions

2022-08-11 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 11, 2022 at 11:06:45PM +, Adam D Ruppe via Digitalmars-d-learn wrote: > You might find my recent blog post interesting too: > > http://dpldocs.info/this-week-in-d/Blog.Posted_2022_08_01.html#exception-template-concept > > and a draft of some more concepts: >

Re: Ranges

2022-08-06 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Aug 06, 2022 at 03:37:32PM +, pascal111 via Digitalmars-d-learn wrote: > On Friday, 5 August 2022 at 04:05:08 UTC, Salih Dincer wrote: > > On Thursday, 4 August 2022 at 22:54:42 UTC, pascal111 wrote: > > > > > > I didn't notice that all what we needs to pop a range forward is > > >

Re: More fun with toStringz and the GC

2022-08-06 Thread H. S. Teoh via Digitalmars-d-announce
On Fri, Aug 05, 2022 at 10:14:24PM -0400, Steven Schveighoffer via Digitalmars-d-announce wrote: > On 8/5/22 8:51 PM, Don Allen wrote: > > > And this, from Section 32.2 of the Language Reference Manual: > > > > If pointers to D garbage collector allocated memory are passed to C > >

Re: Ranges

2022-08-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 05, 2022 at 08:06:00AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > [...] I realized that the following fails with a RangeError: > > void main() { > auto arr = [1, 2, 3]; > arr[0..$-1] = arr[1..$];// <-- Runtime error > } > > I suspect the length of the array is

Re: Obscure Isssue #1

2022-08-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 05, 2022 at 02:23:15PM +, Ruby The Roobster via Digitalmars-d-learn wrote: > On Friday, 5 August 2022 at 14:11:09 UTC, H. S. Teoh wrote: > > On Fri, Aug 05, 2022 at 01:56:40PM +, Ruby The Roobster via > > Digitalmars-d-learn wrote: [...] > > > public import dutils.math.core; >

Re: Obscure Isssue #1

2022-08-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 05, 2022 at 01:56:40PM +, Ruby The Roobster via Digitalmars-d-learn wrote: [...] > public import dutils.math.core; Is the imported module available anywhere? I'm trying to run your code sample to determine what's going on, but it's not compiling because you didn't post the code

Re: curses/ncurses liberary in D

2022-08-04 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 11:52:48PM +, pascal111 via Digitalmars-d-learn wrote: > On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote: > > On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote: > > > > https://github.com/adamdruppe/arsd/blob/master/terminal.d > > > > > > How

Re: How to find all modules in a package?

2022-08-04 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 07:22:04AM +, Domain via Digitalmars-d-learn wrote: > On Wednesday, 3 August 2022 at 12:27:32 UTC, frame wrote: > > On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: > > > I want to find out all public functions in all modules in a package. > > > Can I do that

Re: BigInt.toString

2022-08-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 12:45:44AM +, Ruby The Roobster via Digitalmars-d-learn wrote: > How exactly can one store the string representation of a BigInt? The > seemingly obvious > > ```d > //... > dchar[] ret; //dchar[] is necessary for my project > //Assume that val is a BigInt with a

Re: MMFile usage

2022-08-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 12:35:55AM +, Alex Burton via Digitalmars-d-learn wrote: > Hi, > I want to use MmFile to manage memory mapped files. I want multiple > processes to be able to read in many files using the virtual memory > system to page them in and reuse the memory. > > If I read the

Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64

2022-08-02 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 03, 2022 at 04:28:57AM +, anonymouse via Digitalmars-d-learn wrote: > How do I go about tracking down what's causing the following error: > > ``` > Undefined symbols for architecture x86_64: > "__D3std8internal6memory12__ModuleInfoZ", referenced from: >

Re: Write binary data as a file

2022-08-02 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 02, 2022 at 11:10:27AM +, Alexander Zhirov via Digitalmars-d-learn wrote: [...] > ```d > auto result = db.query("select tcxs.settings_file as dbfile from > amts.t_client_xrdp_settings tcxs where tcxs.pid_client = ?", id); > ubyte[] bytes = cast(ubyte[])result.front()["dbfile"]; >

Re: A converting problem in using "among" with arrays

2022-07-29 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 29, 2022 at 10:32:11PM +, pascal111 via Digitalmars-d-learn wrote: [...] > I want searching for value 54 in array y "54.among(y).writeln;", but > it seems compiler complaints because the data type is "int[]", so I > tried to convert "y" to "uint[]". You're using the wrong

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