where do I find the complete phobos function list names ?

2021-05-25 Thread someone via Digitalmars-d-learn
I was unsuccessfully searching the site for them in the form of a master index to begin with. I need them, in plain text, in order to add them to a VIM custom syntax highlight plugin I already made which I am already using but is lacking phobos support. Can anyone point me to the right place

is there a way to output formatted text following the locale settings ?

2021-05-25 Thread someone via Digitalmars-d-learn
The following works as expected but the format string will end hard-coded: import std.stdio; import std.format; void main ( ) { int intAmount = 1234567; writeln(format("%,d", intAmount)); /// eg: 1,234,567 } I tried something like: import std.stdio; import std.format; import core

Re: where do I find the complete phobos function list names ?

2021-05-25 Thread someone via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 23:46:50 UTC, Paul Backus wrote: If you really want this, your best bet is probably to run a source-code indexer like `ctags` on the Phobos source tree, and do some scripting to transform the results into something usable in your Vim plugin. Something like that cam

Re: is there a way to output formatted text following the locale settings ?

2021-05-25 Thread someone via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 23:41:39 UTC, Paul Backus wrote: From [the documentation of `formattedWrite`][1]: Separator Inserts the separator symbols ',' every X digits, from right to left, into numeric values to increase readability. The fractional part of floating point values inserts t

wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-26 Thread someone via Digitalmars-d-learn
Yes, I know this is a question lacking a straightforward answer. Requirements: - desktop only: forget about support for mobile tablets whatever - wide cross-platform support not needed at all: linux and/or some BSD distro like FreeBSD/DragonFlyBSD and that's all; don't care at all for the Win

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-26 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 02:55:14 UTC, Adam D. Ruppe wrote: Well, you don't strictly have to use gtkd, you can always just extern(C) define the stuff yourself (or only use them from gtkd's generated files) and call them. But if you do use gtk, I'd suggest just sticking to the gtkd wrapper.

Re: where do I find the complete phobos function list names ?

2021-05-27 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 21:21:46 UTC, Christian Köstlin wrote: e.g. I found this file https://dlang.org/library/symbols.js which is used e.g. by https://dlang.org/library/std/algorithm/sorting/sort.html to implement the search. Perhaps that helps. Thanks Christian ! I downloaded the sym

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 01:17:44 UTC, someone wrote: Any comments are welcomed, even any comments regarding anyone experience with GUI development within D, no matter whether the answer would be relevant to my specific question seeking a choice or not. First and foremost, thanks everybod

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 02:55:14 UTC, Adam D. Ruppe wrote: http://arsdnet.net/minigui-linux.png http://arsdnet.net/minigui-sprite.png Thanks a lot for your info :) ! I want you to know that I am replying to myself on the first post summarizing what I already learned researching the subjec

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 09:01:04 UTC, btiffin wrote: libagar is a nice little framework. But, it's C still (and Ada, Perl, COBOL), not D yet. Will see how it goes. Thanks a lot for your info :) ! I want you to know that I am replying to myself on the first post summarizing what I alrea

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 07:00:32 UTC, Imperatorn wrote: I would like to recommend DlangUI [1], but we have tried now for months to get in contact with the owner of it (to take over development) and are getting no reponse. Thanks a lot for your info :) ! I want you to know that I am reply

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 07:20:17 UTC, zjh wrote: I have download FOX.and success compile. I think it is very good.small and beauty. Thanks a lot for your info :) ! I want you to know that I am replying to myself on the first post summarizing what I already learned researching the subject

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 09:11:44 UTC, Виталий Фадеев wrote: sciter, of course. https://sciter.com/ Or write Dlang alternative. Thanks a lot for your info :) ! I want you to know that I am replying to myself on the first post summarizing what I already learned researching the subject st

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 16:49:41 UTC, Dejan Lekic wrote: I humbly believe the most complete one is GtKD. https://gtkdcoding.com/ https://gtkd.org We all wish there was a STANDARD D GUI library out there, but that is a huge effort one or two individuals can't do by themselves (that is why

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Friday, 28 May 2021 at 01:44:24 UTC, zjh wrote: maybe you can try nana. nana ? can you elaborate please ?

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Saturday, 29 May 2021 at 00:57:51 UTC, Marcone wrote: Win32Api. You can use resEdit to create your resource GUI. Work only for Windows. Here is my program created with Dlang and Win32Api GUI: https://sourceforge.net/projects/direct-http-tunnel/ Thanks a lot for your info :) ! I want yo

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-28 Thread someone via Digitalmars-d-learn
On Thursday, 27 May 2021 at 17:04:07 UTC, Alain De Vos wrote: Let's also not forget other languages have problems with gui-toolkits. For instance, gtk-ada binding has memory leaks. gtk-crystal binding is broken. I would like to see a binding to wxwidgets which is a very cool toolkit. It seems

Re: is there a way to output formatted text following the locale settings ?

2021-05-28 Thread someone via Digitalmars-d-learn
On Wednesday, 26 May 2021 at 00:40:30 UTC, Paul Backus wrote: In that case, you will want to use the C library functions from [`core.stdc.stdio`][1]. ```d import core.stdc.stdio; import core.stdc.locale; import std.stdio; void main ( ) { core.stdc.locale.setlocale(LC_ALL, ""); int in

Re: is there a way to output formatted text following the locale settings ?

2021-05-28 Thread someone via Digitalmars-d-learn
On Saturday, 29 May 2021 at 02:59:43 UTC, Paul Backus wrote: D warns for format specifiers that do not conform to the C99 standard, and the `'` flag character is not part of C99. GCC gives a similar warning with `-Wall -pedantic`: Crystal clear !

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-31 Thread someone via Digitalmars-d-learn
On Monday, 31 May 2021 at 02:18:35 UTC, dangbinghoo wrote: don't sell it official, even semi-*. it had very bad platform support, dub support and ... Thanks for the clarification -from what I'm learning and seeing it seems a lot of the toolkits are dead or closer to.

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-31 Thread someone via Digitalmars-d-learn
On Sunday, 30 May 2021 at 12:18:06 UTC, Ola Fosheim Grøstad wrote: There are many GUIS for OpenGL, but OpenGL is no longer supported on Macs AFAIK. Indeed: openGL on all Apple platforms was finally deprecated on 2018 after Apple introduced its own proprietary Metal API. I suggest using Ski

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-31 Thread someone via Digitalmars-d-learn
On Sunday, 30 May 2021 at 12:09:22 UTC, cc wrote: https://streamable.com/2uvt4h cool ... to say the least 😎 !

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-31 Thread someone via Digitalmars-d-learn
On Sunday, 30 May 2021 at 12:27:34 UTC, Siemargl wrote: You forget semi-official DWT For starters I was advised that it is in not good shape. Another one going down :(

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-31 Thread someone via Digitalmars-d-learn
On Sunday, 30 May 2021 at 11:10:31 UTC, Imperatorn wrote: I'm 100% positive you can do good ui using D, but, I'm not sure what I'd choose because of the fragmentation. Of course you can do a good UI on D, C, C++, Rust, or any other system programming language. That is not disputed. From my hu

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-31 Thread someone via Digitalmars-d-learn
On Sunday, 30 May 2021 at 07:03:38 UTC, Chris Piker wrote: Of the 107 forks of dlangui last seen on github ... I can't believe it. What a waste of time/resources. It is like if I forked MATE, changed the title, made 10/20/or-so changes here and there and then dropped out of sight. Pointless.

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-31 Thread someone via Digitalmars-d-learn
On Saturday, 29 May 2021 at 10:52:11 UTC, Alain De Vos wrote: One additional toolkit, fltk, Just checked it: FLTK (aka fulltick) for C++ targeting X with openGL: [screenshots](https://www.fltk.org/shots.php) - we do not depend on text-based attributes (GTK+, MOTIF), complex chains of suppo

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 05:26:47 UTC, Mike Parker wrote: But have you actually investigated it? It's being actively maintained. Being advised not to use it is not the same as saying won't use it; however I consider it a red flag, or to say it in other words, something that I have to pay e

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 06:31:28 UTC, Ola Fosheim Grostad wrote: The solution is to reduce the scope of projects, but that requires design and planning. Hobby projects tend to be experiments that evolve over time. The solution for (at least some critical) projects is to be leaded by a bene

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 10:11:25 UTC, evilrat wrote: Would like to pay for something that's not exists where there is already like 10 "good enough"(tm) alternatives? How much people actually use D and willing to pay for that? Another issue is that these hobby projects are not state of the

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 10:53:54 UTC, Ola Fosheim Grøstad wrote: It is tempting to think that UI-specification is a mature field, but apparently not. It is still evolving. It is a mature field, they peaked in the late 90s early 00s. What came afterwards was mainly decoration/cosmetics bec

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 11:13:49 UTC, zjh wrote: Right,I prefer 1*100% over 3*90%. Without any doubt.

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 11:52:51 UTC, Adam D. Ruppe wrote: Have you ever used github before? No I did not. That's how it works. You "fork" something, do a small change, then open a pull request back to the original. Then your "fork" gets abandoned until next time you want to do a PR. My

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 16:20:19 UTC, Ola Fosheim Grøstad wrote: I don't really agree with this, most of the interesting things for specifying UIs are happening in in web-frameworks/web-standards nowadays. I wasn't considering/referring to content in the browser, this is an entirely diff

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 16:40:22 UTC, IGotD- wrote: This is also my observation. Browser UI is on the way to take over. They are the symptom that the underlying foundations are broken so we go the easy way: like we don't want to standardize the APIs on our OS so lets fire a browser and get

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 21:47:38 UTC, Ola Fosheim Grøstad wrote: Well, on a Mac I would just embed a WebView which already is ready in the OS UI framework. Thanks for the illustration on how you'll eventually proceed with it on the Mac side of things -I use iPhones since the 4 series but f

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 23:16:04 UTC, Ola Fosheim Grøstad wrote: I am of a similar mindset as you, when I use Linux I tend to go minimal WM and setup. It IS depressing how much resources editors use to reach the same fluidity as the editor I used on my Amiga in the 1980s (which used hard

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread someone via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 23:42:58 UTC, someone wrote: Bump. On Tuesday, 1 June 2021 at 23:50:35 UTC, Ola Fosheim Grøstad wrote: Not sure what you meant? errr ... me neither ! Now seriously: attempted to tell you that evidently I know far less than what I think I know. Of course not, D

a=1; b=1; c=1; fine ... now a,b,c=1; ... something like this possible ?

2021-06-04 Thread someone via Digitalmars-d-learn
I think not -just in case.

Re: a=1;b=1;c=1; fine ... now a,b,c=1; ... something like this possible ?

2021-06-04 Thread someone via Digitalmars-d-learn
On Friday, 4 June 2021 at 20:02:28 UTC, drug wrote: a = b = c = 1; fantastic ... спасибо :) !

regarding what seems (to me) unnecessary casts on integer expressions

2021-06-04 Thread someone via Digitalmars-d-learn
Consider the following code to keep track of rectangle positions on the screen; eg: (1,2)(3,2) ie: (left,top)(right,bottom), providing get/set properties for one-based positions but only get properties for zero-based positions: ```d public struct gudtPosition { final public void reset() {

Re: regarding what seems (to me) unnecessary casts on integer expressions

2021-06-04 Thread someone via Digitalmars-d-learn
On Saturday, 5 June 2021 at 01:34:06 UTC, Kyle Ingraham wrote: It looks like you’re being caught by D’s arithmetic conversions: https://dlang.org/spec/type.html#usual-arithmetic-conversions “If the signed type is larger than the unsigned type, the unsigned type is converted to the signed typ

Re: regarding what seems (to me) unnecessary casts on integer expressions

2021-06-04 Thread someone via Digitalmars-d-learn
On Saturday, 5 June 2021 at 02:07:03 UTC, Adam D. Ruppe wrote: This design was a mistake. Of all the great things I learned and read about it, this behavior was totally unexpected to me. It is really difficult to code strong-typed apps this way -this behavior is really wonderful for writin

is it possible to have a default property for any given class ?

2021-06-07 Thread someone via Digitalmars-d-learn
Consider the following code: ```d class classComputer { private string pstrName; final @property string name() { return this.pstrName; } final @property void name(in string lstrName) { this.pstrName = lstrName; } this( string lstrComputerName ) { this.pstrName

Re: is it possible to have a default property for any given class ?

2021-06-07 Thread someone via Digitalmars-d-learn
On Monday, 7 June 2021 at 15:55:36 UTC, H. S. Teoh wrote: Thanks for your reply. It was very illustrating. It's very simple. Whenever some non-array object appears on the right side of a foreach() statement, the compiler looks for a method on the object called .opApply. If it exists, the loop

Re: is it possible to have a default property for any given class ?

2021-06-07 Thread someone via Digitalmars-d-learn
On Monday, 7 June 2021 at 16:10:08 UTC, Jack wrote: I think you meant to implement ranges? you can implement in the way you wanted: ```foreach(lobjComputer; lobjComputers)``` ... Thanks for your reply ! I am aware that ranges are one of D's gems, I did take an overview of them last night or t

Re: regarding what seems (to me) unnecessary casts on integer expressions

2021-06-07 Thread someone via Digitalmars-d-learn
On Monday, 7 June 2021 at 12:53:29 UTC, russhy wrote: Everything is public by default, and you can't overload and derive from structs so final has no effect. There less visual noise. Gotcha ! I started using final (and the like) on classes a couple of days ago and I suppose I unconsciously d

Re: regarding what seems (to me) unnecessary casts on integer expressions

2021-06-07 Thread someone via Digitalmars-d-learn
On Monday, 7 June 2021 at 14:12:14 UTC, H. S. Teoh wrote: Here's my solution to D's short integer cast-madness: abstract it away in an infectious wrapper type. Your workaround seems interesting. Will look further into the concept in the coming days. I am learning the D-ways and there's so muc

best approach to code hierarchical classes ?

2021-06-07 Thread someone via Digitalmars-d-learn
Consider the following code in what I used nested-classes for the first time within D: ```d import std.string; import std.stdio; class classComputers { classComputers lhs; classComputers rhs; int opApply(int delegate(classComputer) dg) { /// boilerplate code to handle the class's de

Re: best approach to code hierarchical classes ?

2021-06-07 Thread someone via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 00:54:41 UTC, someone wrote: Are there alternatives to nested classes for such scenarios ? Self-reply: I created two files for classComputers and classComputer and I replaced the nested-classComputer code within classComputers with: import classComputers; But it

Re: best approach to code hierarchical classes ?

2021-06-07 Thread someone via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 02:05:27 UTC, Paul Backus wrote: Your module and class are both named `classComputers`, with an `s` at the end. You should change one of the to have a different name so that there's no ambiguity. dmd output: ./dm.d(49): Error: undefined identifier `classComputer` i

how to enable safeD ? dmd.conf ? dmd switch ?

2021-06-07 Thread someone via Digitalmars-d-learn
https://dlang.org/articles/safed.html https://dlang.org/dmd-linux.html#switches http://ddili.org/ders/d.en/functions_more.html Neither man dmd nor man dmd.conf appear to have a related/switch setting. Does it means safeD is achieved by placing @safe attributes all over the place ? Or is it ac

Re: how to enable safeD ? dmd.conf ? dmd switch ?

2021-06-07 Thread someone via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 02:59:28 UTC, rikki cattermole wrote: SafeD is an old name given to the attributes @safe @trusted @system. I have the Alexandrescu's book on hand so that explains it. There is no switch nor any special behavior now that it has long been added to mainline D. So DM

Re: how to enable safeD ? dmd.conf ? dmd switch ?

2021-06-07 Thread someone via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 03:54:47 UTC, Jack wrote: better read carefully how the attribute work Good advice. I think I am going too fast. Thank you :)

Re: how to enable safeD ? dmd.conf ? dmd switch ?

2021-06-07 Thread someone via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 04:24:38 UTC, H. S. Teoh wrote: Annotate your functions with @safe. https://dlang.org/spec/function.html#function-safety Best Practices: Mark as many functions @safe as practical. ACK

Re: how to enable safeD ? dmd.conf ? dmd switch ?

2021-06-08 Thread someone via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 07:46:43 UTC, Andrea Fontana wrote: Just mark main() function with @safe and you're done. Fine, thanks :) !

Re: best approach to code hierarchical classes ?

2021-06-09 Thread someone via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 02:37:44 UTC, someone wrote: On Tuesday, 8 June 2021 at 02:05:27 UTC, Paul Backus wrote: Your module and class are both named `classComputers`, with an `s` at the end. You should change one of the to have a different name so that there's no ambiguity. Although I a

what is the proper syntax to inherit a pair of nested classes using templates ?

2021-06-10 Thread someone via Digitalmars-d-learn
I am needing pairs of specific nested classes with already-coded collection management; eg: classComputers having nested classComputer as following (as seen by client code that is): - classComputer ← objComputers.add("ID1", "workstation # 1") - classComputer ← objComputers.add("ID2", "workstati

is there a way to: import something = app-xyz-classes-something; ?

2021-06-20 Thread someone via Digitalmars-d-learn
Since memory serves I use to name files with - instead of the more common _

how to filter associative arrays with foreach ?

2021-06-20 Thread someone via Digitalmars-d-learn
I often need to iterate through a filtered collection (associative array) as following: ```d string strComputerIDunwanted = "WS2"; /// associative array key to exclude foreach (strComputerID, udtComputer; udtComputers) { /// .remove!(a => a == strComputerIDunwanted) ... ? if (strCompute

do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-20 Thread someone via Digitalmars-d-learn
I mean, coding as following: ```d int intWhatever = 0; /// default being zero anyway foreach (classComputer objComputer, objComputers) { ... } /// explicitly declaring the type instead of letting the compiler to figure it out struc Whatever { public doSomething() { ... } /// explicitly d

Re: how to filter associative arrays with foreach ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 08:35:19 UTC, frame wrote: An associative array is not a range but a struct, so it is extra work to create a range from the AA to apply range functions. You can get a range from it by using something like std.array.byPair() but for this usage you would be better of

Re: how to filter associative arrays with foreach ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 21:00:42 UTC, Elronnd wrote: Here's how I would do it: foreach (k, v; coll) { if (k == unwanted) continue; ... } You still have an if, but the actual loop body doesn't have to be nested, so it's easy to follow the control flow. almost the same

Re: how to filter associative arrays with foreach ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 22:08:56 UTC, Steven Schveighoffer wrote: It's actually visually shorter than doing the filter. Indeed; in a few very-specific situations I usually write code like this since it allows me to concentrate on the task at hand and not on the details to access the need

Re: how to filter associative arrays with foreach ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 15:32:09 UTC, wjoe wrote: something like this ? ``` D import std.array; import std.algorithm; udtComputers.byPair .filter!(p => p.key != strComputerIDunwanted) .each!( (p) { /* foreach body */ } ); ``` This seems really interesting :) Almost th

Re: is there a way to: import something = app-xyz-classes-something; ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 13:29:59 UTC, Steven Schveighoffer wrote: It does work. However, you have to tell the compiler the file to compile. When an import is used, the compiler does 2 stages: 1. Search through already-seen modules, and see if one matches 2. Search the filesystem to find a

Re: do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 08:06:06 UTC, frame wrote: Even if it would have an impact - it may change with a new compiler release. I personally use explicit declaration in a foreach loop, because the IDEs don't get the type and it cost me more time to figure out the method signature on objects

Re: do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 13:23:04 UTC, Steven Schveighoffer wrote: For sure there is a difference in what the compiler has to do. Indeed. But I think the check is likely trivial, and inconsequential as far as compiler runtimes. D is going to already figure out the types of expressions *w

Re: do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-21 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 08:06:06 UTC, frame wrote: Even if it would have an impact ... Furthermore, regardless of the impact, one of the pros of explicitly coding like this is to help future-portings of the base code to another language if need so, the team porting the code won't be requ

is it possible to sort a float range ?

2021-06-23 Thread someone via Digitalmars-d-learn
Please, look for the line marked +++ This is a structure with a public property returning a (still unsorted) range built on-the-fly from already-set properties, a basic range from a to z with n step where some specific values can be added in-between. The range is a float which I am currently

Re: is it possible to sort a float range ?

2021-06-23 Thread someone via Digitalmars-d-learn
On Wednesday, 23 June 2021 at 22:30:29 UTC, Jordan Wilson wrote: ```sort``` returns a ```SortedRange```, and I believe you wish to return a float. no, I want to return the range (full of floats) sorted -think it amount or prices or whatever

Re: is it possible to sort a float range ?

2021-06-23 Thread someone via Digitalmars-d-learn
On Wednesday, 23 June 2021 at 22:46:28 UTC, Steven Schveighoffer wrote: Use the `release` method: ```d return lnumRange.sort!(...).release; ``` -Steve Fantastic, issue solved, I previously used sort ascending even descending but first time on floats. So I went and searched phobos docs:

Re: is it possible to sort a float range ?

2021-06-23 Thread someone via Digitalmars-d-learn
On Thursday, 24 June 2021 at 01:36:47 UTC, Ali Çehreli wrote: import std.algorithm; lnumRange.sort!(r"a > b"c); return lnumRange; The above works OK. Funny thing indeed, at least to me, totally unexpected. ```d return lnumRange.sort!(r"a > b"c); /// does not work return l

Re: how to filter associative arrays with foreach ?

2021-06-23 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 08:31:16 UTC, Ali Çehreli wrote: Two options for byKey and byKeyValue: import std; void main() { auto aa = [ "WS2" : 42, "WS3" : 43 ]; string strComputerIDunwanted = "WS2"; foreach (key; aa.byKey.filter!(k => k != strComputerIDunwanted)) { writeln(key, '

Re: is it possible to sort a float range ?

2021-06-24 Thread someone via Digitalmars-d-learn
On Thursday, 24 June 2021 at 05:39:22 UTC, jfondren wrote: - ok, it's useful that it's like this Albeit (the grumbling and) the weirdness of it, this is exactly the reason why I am not complaining on such behavior -time will show me.

Re: is there a way to: import something = app-xyz-classes-something; ?

2021-06-25 Thread someone via Digitalmars-d-learn
On Monday, 21 June 2021 at 13:29:59 UTC, Steven Schveighoffer wrote: That being said, I strongly recommend just to name the file the same as the module name. Although you made it clear that you do not favor this use-case I am really satisfied with your solution because, at least to me, has

Re: is there a way to: import something = app-xyz-classes-something; ?

2021-06-26 Thread someone via Digitalmars-d-learn
On Saturday, 26 June 2021 at 04:24:05 UTC, frame wrote: If you pass each file to the compiler like in your script then every naming convention becomes irrelevant because the compiler does not need to do a file system lookup anyway and a module "foo_bar" could be also in the file xyz.d. You p

Re: How to execute a random postgresql-query.

2021-06-29 Thread someone via Digitalmars-d-learn
On Monday, 28 June 2021 at 19:16:40 UTC, Alain De Vos wrote: How to execute a random postgresql-query ? With random i mean execute any string as known by postgresql. void myexecutefunction(string string_to_execute){ // Some code to Execute postgre-sq-string } ... void main(){ myexecutefunctio

Re: How to execute a random postgresql-query.

2021-06-29 Thread someone via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 17:56:54 UTC, neuranuz wrote: You could also try to find some ready to use bindings to PostgreSQL on code.dlang.org. Can you elaborate why you went your own way coding your own bindings to pglib instead of using the existing ones ? Is there something wrong with t

Re: How to execute a random postgresql-query.

2021-06-29 Thread someone via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 20:27:15 UTC, Alain De Vos wrote: Some implementations take all queries full in memory. But what when i need one record. And the select result could be huge. If the result is huge and you just need one record ... ain't you coding the query wrong to begin with ? S

Re: How to execute a random postgresql-query.

2021-06-29 Thread someone via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 23:32:21 UTC, SealabJaster wrote: Not who you were asking but: they just don't work. Doesn't matter, you're welcome :) Maybe they don't support Windows for one reason or another. Maybe their abstraction for whatever reason isn't able to handle basic types for th

float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-29 Thread someone via Digitalmars-d-learn
Is the following code block valid ? ```d float price; /// initialized as float.nan by default ... right ? if (price == float.nan) { /// writeln("initialized"); } else { /// writeln("uninitialized"); } ``` if so, the following one should be valid too ... right ? ```d float price; if

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-29 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 03:32:27 UTC, Vladimir Panteleev wrote: Comparison with `nan` always results in `false`: THAT explains a lot ! See section 10.11.5: missed it. One of the things I do not like with D, and it causes me to shoot me on the foot over and over, is the lack of nul

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-29 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 03:51:47 UTC, Mathias LANG wrote: or use `std.math.isNaN`. ```d import std.math : isNaN; float lnumStockPricePreceding; foreach (float lnumStockPrice; ludtStockPriceEvolution.range) if (! isNan(lnumStockPricePreceding)) { /// do something } ln

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-29 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 03:55:05 UTC, Vladimir Panteleev wrote: If you want to give any type a "null" value, you could use [`std.typecons.Nullable`](https://dlang.org/library/std/typecons/nullable.html). Practically Nullable!T stores a T and a bool. I like the idea :)

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-29 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 03:55:05 UTC, Vladimir Panteleev wrote: If you want to give any type a "null" value, you could use [`std.typecons.Nullable`](https://dlang.org/library/std/typecons/nullable.html). At LEAST for some things with currency types like prices which cannot be zero beca

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-30 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 09:36:34 UTC, Dennis wrote: A `string` is not a class but an array, an `immutable(char)[]`. You're right. My fault.

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-30 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 10:38:05 UTC, jmh530 wrote: You've never given something away for free? ... more often than usual LoL Now, seriously, something for free has not a price = 0, it has NO price, that's what null is for; we use zero for the lack of null.

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-30 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 16:24:38 UTC, Andre Pany wrote: Side note: in case you want to work with money, you may consider using a specific data type like https://code.dlang.org/packages/money instead of float/double. Yes, I've seen it, and in a previous-unrelated post I commented I am p

Error: function `...` without `this` cannot be `const`

2021-06-30 Thread someone via Digitalmars-d-learn
I do not understand the compiler error when I add the const keyword in the following function which works (and compiles) as expected without the const keyword: ```d public string getAmountSI( in float lnumAmount ) const { /// (1) given amount string lstrAmount; if (lnumAmount

Re: Error: function `...` without `this` cannot be `const`

2021-06-30 Thread someone via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 18:10:52 UTC, Alexandru Ermicioi wrote: That is because const/immutable/shared are being applied on the object hence 'this' variable inside function body if function is a member of a struct or class. So this will make sense ONLY for an object's method right ?

how much "real-life" code can be marked @safe ?

2021-07-01 Thread someone via Digitalmars-d-learn
... just wondering: I am writing pretty trivial code, nothing out of the ordinary, and attempted to check how much of it could be marked safe ... - Lots of tiny common library functions are pretty easy - Getter/Setter properties are easy too - almost all this() constructors are a no-go provi

Re: Error: function `...` without `this` cannot be `const`

2021-07-01 Thread someone via Digitalmars-d-learn
On Thursday, 1 July 2021 at 19:15:50 UTC, Johan Lermer wrote: Isn't @property kind of deprecated? The docs state "experimental" not deprecated ... but what this means today I don't know.

do we already have sum-modulo-10 algo (aka Luhn's algo) on phobos ?

2021-07-03 Thread someone via Digitalmars-d-learn
https://en.wikipedia.org/wiki/Luhn_algorithm#Pseudocode_implementation

mixin template's alias parameter ... ignored ?

2021-07-10 Thread someone via Digitalmars-d-learn
```d mixin template templateUGC ( typeStringUTF, alias lstrStructureID ) { public struct lstrStructureID { typeStringUTF whatever; } } mixin templateUGC!(string, "gudtUGC08"); mixin templateUGC!(dstring, "gudtUGC16"); mixin templateUGC!(wstring, "gudtUGC32"); void main(

Re: mixin template's alias parameter ... ignored ?

2021-07-10 Thread someone via Digitalmars-d-learn
On Sunday, 11 July 2021 at 05:54:48 UTC, Ali Çehreli wrote: The only way that I know is to take a string parameter and use it with a string mixin: Yes, that I tried, but the structure has a lot of lines of codes and so it is impractical and of course it will turn out difficult to debug. Si

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread someone via Digitalmars-d-learn
On Sunday, 11 July 2021 at 13:14:23 UTC, Steven Schveighoffer wrote: when I've done this kind of stuff, what I usually do is: ```d struct Thing { ... // actual struct } mixin("alias ", lstrStructureID, " = Thing;"); ``` the downside is that the actual struct name symbol will be `Thing`, o

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread someone via Digitalmars-d-learn
On Sunday, 11 July 2021 at 12:49:28 UTC, Adam D Ruppe wrote: Indeed, you'd have to mixin the whole thing like mixin("public struct " ~ lstrStructureId ~ " { ... } "); As I mentioned in my previous reply to Ali this could be viable for one-liners-or-so, but for chunks of code having, say, a

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread someone via Digitalmars-d-learn
On Sunday, 11 July 2021 at 05:54:48 UTC, Ali Çehreli wrote: Ali Primarily to Ali & Steve for their help, be advised, this post will be somehow ... long. Some bit of background to begin with: a week or so ago I posted asking advice on code safeness, and still I didn't reply to the ones tha

Re: mixin template's alias parameter ... ignored ?

2021-07-12 Thread someone via Digitalmars-d-learn
On Monday, 12 July 2021 at 05:33:22 UTC, ag0aep6g wrote: Bug: You mixed up `wstring` and `dstring`. `wstring` is UTF-16. `dstring` is UTF-32. I can't believe this one ... these lines were introduced almost a week ago LoL ! Style: `typeStringUTF` is a type, so it should start with a capital

Re: mixin template's alias parameter ... ignored ?

2021-07-12 Thread someone via Digitalmars-d-learn
On Monday, 12 July 2021 at 23:18:57 UTC, jfondren wrote: On Monday, 12 July 2021 at 22:35:27 UTC, someone wrote: Bug: `scope` makes no sense if you want to return `lstrSequence` (throughout). Teach me please: if I declare a variable right after the function declaration like this one ... ain't

  1   2   >