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

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

2021-06-29 Thread Mathias LANG via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 04:03:24 UTC, someone wrote: On Wednesday, 30 June 2021 at 03:51:47 UTC, Mathias LANG wrote: ... is far from pretty but it works as expected, thanks for your tip ! Can be made a bit prettier with UFCS: ```d import std.math : isNaN; float

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: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 }

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

2021-06-29 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 03:52:51 UTC, someone wrote: 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 null for *every* data type. Things like: If you want to give any type a "null" value, you could use

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

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

2021-06-29 Thread Mathias LANG via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 03:32:27 UTC, Vladimir Panteleev wrote: On Wednesday, 30 June 2021 at 03:15:46 UTC, someone wrote: Is the following code block valid ? Comparison with `nan` always results in `false`: See section 10.11.5:

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

2021-06-29 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 03:15:46 UTC, someone wrote: Is the following code block valid ? Comparison with `nan` always results in `false`: See section 10.11.5: https://dlang.org/spec/expression.html#equality_expressions You can use the `is` operator to perform bitwise comparison, or

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: 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

Re: How to execute a random postgresql-query.

2021-06-29 Thread SealabJaster via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 18:25:52 UTC, someone wrote: Can you elaborate why you went your own way coding your own bindings to pglib instead of using the existing ones ? Not who you were asking but: they just don't work. Maybe they don't support Windows for one reason or another. Maybe

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 ?

Re: How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread vnr via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 20:40:29 UTC, Steven Schveighoffer wrote: On 6/29/21 4:25 PM, vnr wrote: [...] Has nothing to do with sessions, you are saving the text posted, and then making it the default text whenever the page is rendered.

Re: How to execute a random postgresql-query.

2021-06-29 Thread apz28 via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 20:35:07 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. And we don't want swapping for this? You can try my db package

Re: How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/29/21 4:25 PM, vnr wrote: Nevertheless, the problem persists and seems to be even deeper, indeed, my site is hosted on Heroku and I can see what a user who is on another machine has written (behavior I just found out). Fortunately, this little site is only for entertainment purposes, but

Re: How to execute a random postgresql-query.

2021-06-29 Thread Alain De Vos via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 20:27:15 UTC, Alain De Vos wrote: On Tuesday, 29 June 2021 at 18:25:52 UTC, someone wrote: 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

Re: How to execute a random postgresql-query.

2021-06-29 Thread Alain De Vos via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 18:25:52 UTC, someone wrote: 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

Re: How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread vnr via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 19:05:43 UTC, WebFreak001 wrote: On Tuesday, 29 June 2021 at 16:25:09 UTC, vnr wrote: Hello  I have a bit of a problem that seems simple enough, but I can't find an answer to my questions. On my website, I have two textareas that the user can write on. When the

Re: How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 16:25:09 UTC, vnr wrote: Hello  I have a bit of a problem that seems simple enough, but I can't find an answer to my questions. On my website, I have two textareas that the user can write on. When the user reloads the page or closes it and then reopens it, the

Re: How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 29 June 2021 at 19:05:43 UTC, WebFreak001 wrote: [...] I should add that this is a convenience feature for users and you should avoid setting this unless it absolutely doesn't make sense that stuff is prefilled for the user. It's there to keep input in case you accidentally

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

Re: How to execute a random postgresql-query.

2021-06-29 Thread neuranuz via Digitalmars-d-learn
insert into person (first_name, second_name) select inp.* from inp "); The last strings should be: insert into person (first_name, second_name) select inp.* from inp ", first_names, last_names);

Re: How to execute a random postgresql-query.

2021-06-29 Thread neuranuz 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(){

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(){

Re: How to execute a random postgresql-query.

2021-06-29 Thread neuranuz 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(){

How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread vnr via Digitalmars-d-learn
Hello  I have a bit of a problem that seems simple enough, but I can't find an answer to my questions. On my website, I have two textareas that the user can write on. When the user reloads the page or closes it and then reopens it, the text he wrote is still written, which is quite