Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 30, 2019 at 04:13:03PM +, Patrick Schluter via Digitalmars-d-learn wrote: [...] > Good point. It also trains people to not be able to work without IDE. > I see it at work with some of the Java devs who aren't even able to > invoke javac in a command line and setting javapath

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 30, 2019 at 02:59:22PM +, bachmeier via Digitalmars-d-learn wrote: [...] > An IDE adds a crapload to the learning curve. It's terrible, because > they need to memorize a bunch of steps when they use a GUI (click here > -> type this thing in this box -> click here -> ...) [...] To

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-29 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 29, 2019 at 09:25:44PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Sunday, 29 December 2019 at 14:41:46 UTC, Russel Winder wrote: > > Whilst many programmers are happy using 1970s approaches > > Please. Have you actually spent the time to learn these systems in the >

Re: What type does byGrapheme() return?

2019-12-27 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 27, 2019 at 06:26:58PM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > I love these documentation lines in the D docs: > > auto byGrapheme(Range)(Range range) > > How should I know what auto is? Why not write the explicit type so > that I know what to expect? When

Re: D-ish way to work with strings?

2019-12-27 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 27, 2019 at 01:23:57PM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2019-12-23 15:05:20 +, H. S. Teoh said: [...] > > What are you planning to do with your strings? > > Pretty simple: Have user editable content that is rendered using > different fonts supporting

Re: [OT] What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 24, 2019 at 07:46:27PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: [...] > I just got sick of ls printing green on white and hurting my eyes. Or > blue on black. Haha, one of the first things I do upon installing a new Linux system is to turn off ls colors. :-D Hurts the

Re: [OT] What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 24, 2019 at 10:18:49AM +, Russel Winder via Digitalmars-d-learn wrote: > On Mon, 2019-12-23 at 08:09 -0800, H. S. Teoh via Digitalmars-d-learn > wrote: > […] > > No idea, I use vanilla vim (not even with syntax highlighting -- I'm > > a hardcore retro guy). &

Re: Deprecation: std.stdio.File.ByChunkImpl is not visible

2019-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 24, 2019 at 12:33:34AM +, psyscout via Digitalmars-d-learn wrote: [...] > auto putObjectRequest(string bucket, string key, string file) > { > import std.stdio : File; > > enum chunk_size = 16 * 1024; // 16 KiB > auto file_ = File(file, "r"); > > return

Re: unicode characters are not printed correctly on the windows command line?

2019-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 23, 2019 at 10:41:33AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > There's this guy, his name is Walter. He likes printf. I'm pretty sure > when he's buried, his cold dead fingers will be tightly and > inextricably wrapped around printf. [...] But that's not a

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 23, 2019 at 03:51:17PM +, bachmeier via Digitalmars-d-learn wrote: > On Monday, 23 December 2019 at 15:07:32 UTC, H. S. Teoh wrote: [...] > > Linux is my IDE. ;-) And I use vim for editing code. [...] > Not a Vim user, but wondering if there's Neovim support for D. If so, > it

Re: unicode characters are not printed correctly on the windows command line?

2019-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 22, 2019 at 10:04:20PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: [...] > Regardless, I'm pretty well of the opinion that fwrite is the wrong > thing to do anyway. fwrite writes bytes to a file, but we want to > write strings to the console. There's other functions that do

Re: What would it take to bring preinstalled D language compiler in the major Linux Distributions?

2019-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 23, 2019 at 01:34:55PM +, BoQsc via Digitalmars-d-learn wrote: > I would love to see D language available out of box in major Linux > distributions and use without much care of installation. Anyone have a > though about it? Was there any serious efforts to bring D language to >

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 22, 2019 at 05:20:51PM +, BoQsc via Digitalmars-d-learn wrote: > There are lots of editors/IDE's that support D language: > https://wiki.dlang.org/Editors > > What kind of editor/IDE are you using and which one do you like the most? Linux is my IDE. ;-) And I use vim for editing

Re: D-ish way to work with strings?

2019-12-23 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 22, 2019 at 06:27:03PM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > Want to add I'm talking about unicode strings. > > Wouldn't it make sense to handle everything as UTF-32 so that > iteration is simple because code-point = code-unit? > > And later on, convert to UTF-16

Re: Problem with public example in Phobos

2019-12-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 18, 2019 at 07:16:15PM +, berni44 via Digitalmars-d-learn wrote: > On Wednesday, 18 December 2019 at 17:57:15 UTC, Steven Schveighoffer wrote: [...] > > Note, putting unittests inside templates duplicates the unit test > > for every instantiation. Using an instantiation other than

Re: Fastest way to check if the bottom-class of a class reference is any of a set of classes

2019-12-16 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 16, 2019 at 02:38:59PM +, Per Nordlöw via Digitalmars-d-learn wrote: > What is the fastest way to check whether a class reference is an instance of > a > bottom equal to any in a set of classes? My current try is something like > > class C {} > > class X : C {} > class Y : C {}

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 04, 2019 at 01:01:04AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote: > > Option 4: typeof(return) > > typeof(return) is super cool for like option type things too! typeof(return) is one of the lesser known cool things

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 09:08:55PM +, Paul Backus via Digitalmars-d-learn wrote: > On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: > > The thing is, `void` means "no return type" (or "no type" in some > > contexts), i.e., void == TBottom in that case. > > This is incorrect.

Re: Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 09:22:49AM +, Jan Hönig via Digitalmars-d-learn wrote: > Today i have stumbled on Hacker News into: https://0.30004.com/ > > I am learning D, that's why i have to ask. > > Why does > > writefln("%.17f", .1+.2); > > not evaluate into:

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 03:19:02AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- > learn wrote: [...] > > [...] maybe we should be able to name the type of null. I think this > > relates to TBottom too a bit. > >

Re: why local variables cannot be ref?

2019-11-25 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Nov 25, 2019 at 08:39:08PM +, Fanda Vacek via Digitalmars-d-learn wrote: > On Monday, 25 November 2019 at 08:32:53 UTC, H. S. Teoh wrote: > > On Mon, Nov 25, 2019 at 08:07:50AM +, Fanda Vacek via > > Digitalmars-d-learn wrote: [...] > > > But anyway, pointers are not allowed in

Re: why local variables cannot be ref?

2019-11-25 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Nov 25, 2019 at 08:07:50AM +, Fanda Vacek via Digitalmars-d-learn wrote: [...] > But anyway, pointers are not allowed in @safe code, so this is not > always solution. [...] This is incorrect. Pointers *are* allowed in @safe code. Pointer *arithmetic* is not allowed. --T

Re: No UFCS with nested functions?

2019-11-04 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Nov 04, 2019 at 07:51:26PM +, Tobias Pankrath via Digitalmars-d-learn wrote: > Why does the following not work? It works, if I move the 'prop' out of > 'foo'. UFCS is only supported for module-level functions, as far as I know. > --- > struct S { > ubyte[12] bar; > } > >

Re: Accuracy of floating point calculations

2019-10-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 31, 2019 at 09:52:08AM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2019-10-30 15:12:29 +, H. S. Teoh said: [...] > > Do you mean *simulated* 128-bit reals (e.g. with a pair of 64-bit > > doubles), or do you mean actual IEEE 128-bit reals? > > Simulated, because HW

Re: Accuracy of floating point calculations

2019-10-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 30, 2019 at 09:03:49AM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2019-10-29 17:43:47 +, H. S. Teoh said: > > > On Tue, Oct 29, 2019 at 04:54:23PM +, ixid via Digitalmars-d-learn > > wrote: > > > On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak

Re: Accuracy of floating point calculations

2019-10-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 29, 2019 at 07:10:08PM +, Twilight via Digitalmars-d-learn wrote: > On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: > > On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: > > > If you use gdc or ldc you will get same results as c++, or you can > > > use C log

Re: Accuracy of floating point calculations

2019-10-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 29, 2019 at 04:54:23PM +, ixid via Digitalmars-d-learn wrote: > On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: > > On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: > > > If you use gdc or ldc you will get same results as c++, or you can > > > use C log

Re: formatting a float or double in a string with all significant digits kept

2019-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 10, 2019 at 09:13:05PM +, Jon Degenhardt via Digitalmars-d-learn wrote: > On Thursday, 10 October 2019 at 17:12:25 UTC, dan wrote: > > Thanks also berni44 for the information about the dig attribute, Jon > > for the neat packaging into one line using the attribute on the > > type.

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

2019-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 10, 2019 at 03:58:02PM +, jmh530 via Digitalmars-d-learn wrote: > On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: > > In C# you can do something like: > > > > > > if (obj is Person) > > { > > var person = obj as Person; > > // do stuff with

Re: Functional Programming in D

2019-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 10, 2019 at 09:59:49AM +0100, Russel Winder via Digitalmars-d-learn wrote: > On Wed, 2019-10-09 at 11:12 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > > Actually, std.functional is somewhat of a misnomer. It mostly deals > > with higher-order function

Re: Functional Programming in D

2019-10-09 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 09, 2019 at 05:41:02PM +, Jonathan Gerlach via Digitalmars-d-learn wrote: > On Wednesday, 9 October 2019 at 14:26:53 UTC, NonNull wrote: > > Hello, > > I want to become fluent in the use of functional programming > > techniques in D (as well as the use of ranges) using

Re: Dynamic Arrays as Stack and/or Queue

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

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

2019-10-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 04, 2019 at 07:21:34PM +, Dennis via Digitalmars-d-learn wrote: > On Friday, 4 October 2019 at 18:53:30 UTC, H. S. Teoh wrote: > > Here's an actual working example that illustrates the pitfall of > > this implicit conversion: > > Luckily it's caught by -dip1000 Nice! T -- "A

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

2019-10-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 04, 2019 at 07:08:04PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Friday, 4 October 2019 at 19:03:14 UTC, Dennis wrote: > > You're right, I'm confused. I recall there was a situation where you > > had to explicitly slice a static array, but I can't think of it now. > >

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

2019-10-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 04, 2019 at 11:43:34AM -0700, H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, Oct 04, 2019 at 06:34:40PM +, Dennis via Digitalmars-d-learn > wrote: > > On Friday, 4 October 2019 at 18:30:17 UTC, IGotD- wrote: > > > What if you pass a static array to a

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

2019-10-04 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 04, 2019 at 06:34:40PM +, Dennis via Digitalmars-d-learn wrote: > On Friday, 4 October 2019 at 18:30:17 UTC, IGotD- wrote: > > What if you pass a static array to a function that expects a dynamic > > array. Will D automatically create a dynamic array from the static > > array? > >

Re: Struct initialization has no effect or error?

2019-10-02 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 02, 2019 at 05:37:57PM +, Brett via Digitalmars-d-learn wrote: > struct X { int a; } > > X[1] x; > > x[0] = {3}; > > or > > x[0] = {a:3}; > > fails; This works: x[0] = X(123); > Should the syntax not extend to the case of array assignment? Arguably it should. But

Re: Looking for a Simple Doubly Linked List Implementation

2019-09-20 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 20, 2019 at 08:26:03PM +, Ron Tarrant via Digitalmars-d-learn wrote: > Hi guys, > > I've been banging my head on the screen with this one for the last > week or so. For whatever reason, I'm having major problems > understanding how to implement a doubly-linked list in D. I don't

Re: Avoid gratuitous closure allocations

2019-09-20 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 20, 2019 at 01:03:29PM +, Andrea Fontana via Digitalmars-d-learn wrote: > On Friday, 20 September 2019 at 11:21:22 UTC, Ali Çehreli wrote: > > tl;dr Instead of returning an object that uses local state, return > > an object that uses member variables. > > Really good to know

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 18, 2019 at 12:37:28PM +, Simen Kjærås via Digitalmars-d-learn wrote: [...] > template MergeOverloads(T...) { > alias MergeOverloads = T[0]; > static if (T.length > 1) { > alias MergeOverloads = MergeOverloads!(T[1..$]); > } > } > > I would however label that

Re: Deprecation message sources

2019-09-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 18, 2019 at 10:48:27AM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 9/17/19 8:14 PM, Jonathan M Davis wrote: [...] > > I suspect that deprecation messages are being triggered simply by > > code trying to use Nullable in template constraints rather than just > > when

Re: Deprecation message sources

2019-09-17 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Sep 17, 2019 at 08:55:27PM +, Johan Engelen via Digitalmars-d-learn wrote: [...] > Wow. How come this is not caught by the CI testing? [...] Is the CI setup to detect deprecations and flag them as failures? It's either that, or many cases are not tested because Phobos has a lot of

Re: Name change weird

2019-09-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 13, 2019 at 05:57:53AM +, Joel via Digitalmars-d-learn wrote: [...] > jex(2204,0x75356000) malloc: Incorrect checksum for freed object > 0x7ffc9368cdf8: probably modified after being freed. > Corrupt value: 0x7ffc9368000d > jex(2204,0x75356000) malloc: *** set a breakpoint

Re: How to use xargs to remove whitespaces (Dub executable path)

2019-09-04 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 04, 2019 at 05:52:12AM +, Andre Pany via Digitalmars-d-learn wrote: > Hi, > > I try to get the executable path from a dub package using this command: > > dub describe dscanner --data=target-path,target-name --data-list | xargs > > But the output always contains a space between

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

2019-08-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 30, 2019 at 04:45:20PM +, berni via Digitalmars-d-learn wrote: > On Friday, 30 August 2019 at 15:00:59 UTC, Paul Backus wrote: > > Whether you actually get an error at runtime depends on the load > > factor of the AA. If it drops below a certain threshold, the AA will > > be

Re: Pro programmer

2019-08-27 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 27, 2019 at 04:01:03PM +, GreatSam4sure via Digitalmars-d-learn wrote: > On Tuesday, 27 August 2019 at 14:51:07 UTC, Ron Tarrant wrote: > > On Sunday, 25 August 2019 at 21:30:10 UTC, GreatSam4sure wrote: > > > If I want to be a pro programmer what language must I start with? > >

Re: Linking D Runtime

2019-08-23 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Aug 24, 2019 at 12:26:43AM +, Jonathan Levi via Digitalmars-d-learn wrote: > I am trying to find the D runtime/standard-library > object(.o)/library(.a) files inorder to link them with some foreign > code (Haskell as it happens). > > I am writing a program in Haskell but want to use

Re: Template specialized functions creating runtime instructions?

2019-08-20 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 20, 2019 at 11:48:04PM +, ads via Digitalmars-d-learn wrote: [...] > In the generated assembly, it looks like it is creating a lot of > runtime instructions, contrary to my belief that templated codes are > purely compile-time. I was expecting that the compiler would deduce > the

Re: What is "dmd" Internal API, can I use it just like std Library Reference?

2019-08-20 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 20, 2019 at 12:52:31PM +, BoQsc via Digitalmars-d-learn wrote: [...] > I found https://dlang.org/phobos/dmd_console.html and wanted to use > it. But it seems I'm not being successful, and I do not understand > why. [...] Because this is code inside the compiler, when you're

Re: Slow UDF call?

2019-08-18 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Aug 17, 2019 at 09:42:00PM +, Giovanni Di Maria via Digitalmars-d-learn wrote: [...] > I have also compiled with: > dmd program.d -O -release -inline -boundscheck=off > > and the execution speed is very very fast. [...] If performance is important to you, I recommend checking out

Re: string to ubyte[]

2019-08-14 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 14, 2019 at 03:11:44PM +, berni via Digitalmars-d-learn wrote: [...] > but unfortunately this does not work: > > >ubyte[] convert_string_pair(string first, string second) > >{ > >return 0x00 ~ first ~ 0x00 ~ second ~ 0x00; > >} > > The reason is, that this

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

2019-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 13, 2019 at 08:42:37PM +, Max Haughton via Digitalmars-d-learn wrote: > On Tuesday, 13 August 2019 at 18:54:58 UTC, H. S. Teoh wrote: [...] > > These days, with CPU multi-level caches and memory access > > predictors, in-place arrays are often the best option for > > performance,

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

2019-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 13, 2019 at 11:28:35AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > Summary: Ditch the linked list and put the elements into an array. :) [...] +1. The linked list may have been faster 20 years ago, before the advent of modern CPUs with caching hierarchies and memory

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

2019-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 13, 2019 at 12:12:28PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: > On Tuesday, August 13, 2019 11:33:10 AM MDT Mirjam Akkersdijk via > Digitalmars-d-learn wrote: [...] > > Thank you, this is what I eventually chose to do. It's also fairly > > fast, though doesn't the

Re: Is there a way to adjust lookup paths for modules during compilation?

2019-07-31 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 31, 2019 at 08:47:42PM +, Andrey Zherikov via Digitalmars-d-learn wrote: > On Wednesday, 31 July 2019 at 20:16:01 UTC, H. S. Teoh wrote: > > On Wed, Jul 31, 2019 at 08:09:29PM +, Andrey Zherikov via > > Digitalmars-d-learn wrote: > > > I found a function that seems could be

Re: Is there a way to adjust lookup paths for modules during compilation?

2019-07-31 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 31, 2019 at 08:09:29PM +, Andrey Zherikov via Digitalmars-d-learn wrote: > I found a function that seems could be used for adding import paths: > dmd.frontend.addImport > (https://dlang.org/phobos/dmd_frontend.html#.addImport). But it's not clear > how can I use it: dmd directory

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 31, 2019 at 05:09:50PM +, BoQsc via Digitalmars-d-learn wrote: [...] > However as pointed out in the above post, I'm unable to use options in > shebang since apache is throwing header error for unknown reasons. [...] Usually, that's a sign that somebody is writing to stdout/stderr

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

2019-07-29 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 29, 2019 at 05:32:58PM +, Matt via Digitalmars-d-learn wrote: > I've noticed that for some ranges in Phobos empty is marked const > (e.g. iota) but for other ranges (e.g. multiwayMerge) it is not > const. Is there a reason why? Isn't empty guaranteed not to alter the > data of the

Re: __stdin.d(2): Error: found End of File when expecting }

2019-07-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 17, 2019 at 07:05:20PM +, Andre Pany via Digitalmars-d-learn wrote: > Hi, > > this scripts throws 2 times this error: > __stdin.d(2): Error: found End of File when expecting } following compound > statement > __stdin.d(2): Error: found End of File when expecting } following

Re: Conversion problem.

2019-06-25 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 25, 2019 at 12:08:07PM +, Den_d_y via Digitalmars-d-learn wrote: > Hello! Here I am again, with my problem ... In my program, I cannot manage > to convert from "double" to "int". Here is the code: [...] Did you try this? import std.conv : to; double d = ...;

Re: Best practices of using const

2019-06-21 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 21, 2019 at 06:32:33PM +, Yatheendra via Digitalmars-d-learn wrote: [...] >struct CostlyComputeResult { > ... // data fields > // constructor takes compute results, no postblit >} > >struct Wrapper { > const (CostlyComputeResult) *cachee = 0; >

Re: Best practices of using const

2019-06-21 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 21, 2019 at 06:07:59AM +, Yatheendra via Digitalmars-d-learn wrote: > Am I mistaken in saying that we are conflating: >"anything that is logically const should be declared const" No, not in D. D does not have logical const; it has "physical" const, which is a strict subset

Re: Component based programming in D

2019-06-18 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 18, 2019 at 09:22:28PM +, Aurélien Plazzotta via Digitalmars-d-learn wrote: > On Tuesday, 18 June 2019 at 09:17:09 UTC, Bart wrote: > > > Can someone help me understand this a little better and how I'd go > > about using it in D? Specifically I'm looking at the pros and cons, > >

Re: Just another question about memory management in d from a newbie

2019-06-17 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jun 17, 2019 at 07:53:52PM +, Thomas via Digitalmars-d-learn wrote: [...] > int main() > { > foreach(i;0 .. 1) > { > int x; > // do something with x > } > return 0; > } > > Do I understand it right that the variable x will be created 1 > times

Re: How to compile my DMD fork?

2019-06-14 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 14, 2019 at 06:07:11PM +, Q. Schroll via Digitalmars-d-learn wrote: > Basically the headline. I want to try to implement my DIP. I've > already forked DMD from GitHub. Now, what would I have to do in order > to get a D compiler with my changes? [...] This might help:

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

2019-06-12 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 12, 2019 at 07:46:12PM +, Mek101 via Digitalmars-d-learn wrote: [...] > > public size_t indexOf(alias pred = "a == b", Range)(Range array) > > { > > alias predicate = unaryFun!pred; > > for(size_t i = 0; i < array.length; i++) > > if(predicate(array[i])) > >

Re: static variable A cannot be read at compile time

2019-06-12 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 12, 2019 at 01:12:58PM +, Newbie2019 via Digitalmars-d-learn wrote: > https://run.dlang.io/is/s4cfiv > > onlineapp.d(23): Error: static variable A cannot be read at compile time > onlineapp.d(23): Error: cannot implicitly convert expression 1 of type int > to int* > > I see no

Re: D compiler need -nogc witch and document of library also need nogc button

2019-06-11 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 11, 2019 at 02:46:03PM +, dangbinghoo via Digitalmars-d-learn wrote: > On Tuesday, 11 June 2019 at 12:40:39 UTC, Adam D. Ruppe wrote: > > On Tuesday, 11 June 2019 at 08:59:01 UTC, dangbinghoo wrote: > > > We need to make sure we use only @nogc API when writing code, not > > > when

Re: hasElaborateCopyConstructor bug?

2019-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jun 02, 2019 at 02:32:16PM +, Paul Backus via Digitalmars-d-learn wrote: [...] > If std.v2 ever materializes, we'll have an opportunity to fix > papercuts like this. Until then, my preferred workaround is to use a > renaming import: > > import std.traits: hasNontrivialCopy =

Re: Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?

2019-05-23 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, May 23, 2019 at 06:20:23PM +, kdevel via Digitalmars-d-learn wrote: > On Thursday, 23 May 2019 at 09:44:15 UTC, Cym13 wrote: [...] > > To go fast, read/write bigger chunks. > > Or use rawWrite instead of write (reduces the runtime to about 1.6 s). > When using write time is IMHO spent

Re: Why function does not work with delegate

2019-05-22 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 22, 2019 at 10:33:52PM +, Alex via Digitalmars-d-learn wrote: > In gtkD one can use a lambda directly: > > X.addOnButtonPress((GdkEventButton* e, Widget w) ... > > but if I try move the lambda in to a variable so I can use it with > multiple handlers, I get an error: > >

Re: Is using floating point type for money/currency a good idea?

2019-05-20 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, May 20, 2019 at 11:10:32AM +, Boqsc via Digitalmars-d-learn wrote: > https://dlang.org/spec/float.html > > I'm frozen in learning basics of D lang since I want to create a > simple game and I really would like a clean and simple code, however > to me floating points are magic. Read

Re: In what situation can new Struct() return null?

2019-05-10 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, May 10, 2019 at 05:32:25PM +, faissaloo via Digitalmars-d-learn wrote: > On Friday, 10 May 2019 at 12:19:29 UTC, Cym13 wrote: > > On Friday, 10 May 2019 at 10:11:51 UTC, faissaloo wrote: > > > My program contains the following statement: > > > auto newChildNode = new Node(); > > >

Re: Framework design, initialization and framework usage

2019-05-07 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 07, 2019 at 07:21:52PM +0200, Robert M. Münch via Digitalmars-d-learn wrote: [...] > > interface myFrameworkApp { > > void init(); > > } [...] Note: it's a very bad idea to call a member function 'init'. It conflicts with the built-in .init property of all types, and can lead to

Re: Find sequence in binary fiel and advance from there

2019-05-07 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 07, 2019 at 08:26:16AM +, alex1974 via Digitalmars-d-learn wrote: > I want to read a binary file and validate that it contains the > sequence [73,68,51] (ID3). And than start to read from this position > onward. > > I could read in the whole file as an ubyte array but I would

Re: What are some ways to get more strict type-checking?

2019-05-06 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, May 06, 2019 at 02:41:31PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Monday, 6 May 2019 at 02:02:52 UTC, Devin wrote: > > But to my astonishment, the broken code compiled without any > > warnings or notifications. > > Yeah, I kinda wish bool (and char too, while we're at

Re: Any full feature xml library available?

2019-05-03 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, May 03, 2019 at 09:56:56PM +0100, Russel Winder via Digitalmars-d-learn wrote: > On Thu, 2019-05-02 at 09:28 -0700, H. S. Teoh via Digitalmars-d-learn > wrote: > > On Thu, May 02, 2019 at 05:23:29PM +0100, Russel Winder via > > Digital

Re: Linking to OpenCV OSX (dub.json LFLAG)

2019-05-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, May 02, 2019 at 11:24:12PM +, Fred via Digitalmars-d-learn wrote: > Hey Guys, > > Complete Dlang n00b here and I'm having awful problems linking to > opencv using my projects dub.json. > > I've been getting some help on Github > (https://github.com/aferust/opencvd/issues/1) but had

Re: Any full feature xml library available?

2019-05-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, May 02, 2019 at 05:23:29PM +0100, Russel Winder via Digitalmars-d-learn wrote: [...] > There are situations where you create a binding in preference to > writing something from scratch. cf. gtk, gstreamer, etc. so why not > libxml2? [...] No particular reason, except nobody has taken up

Re: Does D have a tool like pySnooper?

2019-04-26 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Apr 26, 2019 at 02:33:16PM +, Taylor Hillegeist via Digitalmars-d-learn wrote: > On Friday, 26 April 2019 at 10:22:49 UTC, Bastiaan Veelo wrote: [...] > > Proofing the concept: > > --- > > mixin(snoop(q{ > > int fun(int a, int b) > > { > > int c = 3; > >

Re: Static struct?

2019-04-24 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Apr 24, 2019 at 09:12:10PM +, JN via Digitalmars-d-learn wrote: > I noticed a construct I haven't seen before in D when reading the > description for automem - https://github.com/atilaneves/automem > > static struct Point { > int x; > int y; > } > > > What does

Re: Unexpected behaviour in associative array

2019-04-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Apr 19, 2019 at 08:15:22PM +, Arredondo via Digitalmars-d-learn wrote: > On Friday, 19 April 2019 at 12:48:32 UTC, Adam D. Ruppe wrote: > > It might just be that toHash is secretly dependent on various > > attributes in the signature. > > > > You nailed it. This was it. It was not

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-10 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Apr 10, 2019 at 11:05:27PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Wednesday, 10 April 2019 at 19:29:13 UTC, Alex wrote: > > I wonder if there are some interesting patterns of nesting is's? > > > > is(...is(...is(...)...)...) > > No, at least not like that. You'd get

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-10 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Apr 10, 2019 at 02:22:35AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 9 April 2019 at 21:00:55 UTC, H. S. Teoh wrote: > > (And on a side note: don't even get me started on is(...) > > expressions.) > > is expressions rock. And I betcha if we did do libraries for

Re: Templates - What's Up with the template keyword?

2019-04-09 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Apr 09, 2019 at 04:48:45PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 4/9/19 4:31 PM, Ron Tarrant wrote: > > > I'm still struggling to understand templates, but I'll keep at it. [...] > The thing that made it click for me is that a template is very akin to > a macro

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-09 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Apr 09, 2019 at 08:49:17PM +, Alex via Digitalmars-d-learn wrote: > On Tuesday, 9 April 2019 at 18:56:58 UTC, H. S. Teoh wrote: [...] > My point has been and is that there is a better way that is more > natural. I make no claims about anything else. It may be a cop out to > say

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-09 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Apr 09, 2019 at 06:33:21PM +, Seb via Digitalmars-d-learn wrote: > On Tuesday, 9 April 2019 at 16:30:53 UTC, Alex wrote: > > On Tuesday, 9 April 2019 at 14:59:03 UTC, Adam D. Ruppe wrote: > > > [...] > > I didn't say the language. The point with the language is that it > > could have

Re: Poor regex performance?

2019-04-04 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Apr 04, 2019 at 09:53:06AM +, Julian via Digitalmars-d-learn wrote: [...] > auto re = ctRegex!(r"(?:\S+ ){3,4}<= ([^@]+@(\S+))"); [...] ctRegex is a crock; use regex() instead and it might actually work better. T -- Stop staring at me like that! It's offens... no, you'll

Re: D interface bug?

2019-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 29, 2019 at 11:44:35PM +, Alex via Digitalmars-d-learn wrote: > interface iBase > { > iBase fooBase(iBase); > } > > > class cBase : iBase > { > cBase fooBase(cBase c) { return c; } > > } > > cBase.fooBase should be a valid override of iBase.fooBase because they

Re: Easiest way to use Linux system C files / tiny C libraries

2019-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 29, 2019 at 10:48:47PM +, Chris Katko via Digitalmars-d-learn wrote: > What's the easiest way to use POSIX and Linux-specific C include > files? That depends on what you're expecting and what you're willing to do yourself. If you want a nicely-packaged, black-box way of using C

Re: Any easy way to extract files to memory buffer?

2019-03-18 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Mar 18, 2019 at 10:38:17PM +, Michelle Long via Digitalmars-d-learn wrote: > On Monday, 18 March 2019 at 21:14:05 UTC, Vladimir Panteleev wrote: > > On Monday, 18 March 2019 at 21:09:55 UTC, Michelle Long wrote: > > > Trying to speed up extracting some files that I first have to > > >

Re: SEGFAULT when converting C string to string

2019-03-18 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Mar 18, 2019 at 10:20:35PM +, DFTW via Digitalmars-d-learn wrote: > I'm writing a shared library in C to be used from a C program, so I > went to my small tests. That one failed give a SEGFAULT on the > std.conv.to call. > > This is the pice of D code/the library: > > extern(C) int

Re: Block statements and memory management

2019-03-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Mar 16, 2019 at 01:21:02PM +0100, spir via Digitalmars-d-learn wrote: > On 16/03/2019 11:19, Dennis via Digitalmars-d-learn wrote: [...] > > In any case, for better memory efficiency I'd consider looking at > > reducing dynamic allocations such as new or malloc. Memory on the > > stack is

Re: Operator Overloading with multiple return types

2019-03-15 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 15, 2019 at 04:29:22PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 03/15/2019 03:48 PM, H. S. Teoh wrote: [...] > > Ali's example was unfortunately deceptively formatted. > > My editor did that. :) This is why I don't trust auto-formatters. ;-) > On my work computer,

Re: Operator Overloading with multiple return types

2019-03-15 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 15, 2019 at 10:30:41PM +, eXodiquas via Digitalmars-d-learn wrote: > On Friday, 15 March 2019 at 21:46:50 UTC, Ali Çehreli wrote: [...] > > Or use template constraints: > > > > struct Vector { > > Vector opBinary(string op)(Vector rhs) > > if (op == "+") { > > return

Re: Operator Overloading with multiple return types

2019-03-15 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 15, 2019 at 09:35:12PM +, eXodiquas via Digitalmars-d-learn wrote: [...] > Vector opBinary(string op)(Vector rhs) > { > static if (op == "+") return Vector(this.x + rhs.x, this.y + rhs.y); > else static if (op == "-") return Vector(this.x - rhs.x, this.y - > rhs.y); > } >

Re: why is ifThrown un@safe?

2019-03-15 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 15, 2019 at 06:46:25PM +, bauss via Digitalmars-d-learn wrote: > On Friday, 15 March 2019 at 18:04:05 UTC, Bastiaan Veelo wrote: > > In the code below (https://run.dlang.io/is/d0oTNi), ifThrown is > > inferred as un@safe. If instead I write the implementation of > > ifThrown out

Re: Operator overloading for size_t

2019-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2019 at 06:07:46PM +, Alec Stewart via Digitalmars-d-learn wrote: [...] > bool opEquals(ref const Interval i) const { > // probably would be a bit more than just this, but for this issue > // let's just stick with this. > return

Re: bug in doc?

2019-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2019 at 03:22:52PM +0100, spir via Digitalmars-d-learn wrote: > https://dlang.org/spec/hash-map.html#static_initialization: > > immutable long[string] aa = [ > "foo": 5, > "bar": 10, > "baz": 2000 > ]; > > ==> Error: non-constant expression `["foo":5L, "bar":10L,

Re: local class instance (at module-level)

2019-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2019 at 12:05:22PM +0100, spir via Digitalmars-d-learn wrote: > I desperately try to declare/define/initialise a simple class instance > at module-level. This is a special (conceptually static and immutable) > instance used as a "marker", that just should exist and be accessible >

<    3   4   5   6   7   8   9   10   11   12   >