Re: ugly and/or useless features in the language.

2021-05-17 Thread Berni44 via Digitalmars-d-learn
On Saturday, 15 May 2021 at 14:31:08 UTC, Alain De Vos wrote: Which parts in dlang don't you use and why? There is one feature (actually a mix of features) I'd be happy not to use, but it is not possible: I call it autoreals, because it resembles somewhat the idea behind autodecoding - in

Re: Any suggestions on dmd error message formatting?

2021-05-15 Thread Berni44 via Digitalmars-d-learn
On Saturday, 15 May 2021 at 04:54:15 UTC, Chris Piker wrote: As always, your advice is much appreciated I'm usually piping the results through hexdump. ;-) No, in earnest, I often would have liked to have better formatted messages. The only thing I can say: Sometimes it helps to increase

Re: Is inc function part of the library ?

2021-05-13 Thread Berni44 via Digitalmars-d-learn
On Thursday, 13 May 2021 at 11:21:58 UTC, Alain De Vos wrote: [...] how can I do an extensive search in the library to functions when i know more or less their name , but don't know their exact place as module or package. An alternative to the official documentation is

Re: Issue with small floating point numbers

2021-05-13 Thread Berni44 via Digitalmars-d-learn
On Thursday, 13 May 2021 at 03:03:37 UTC, Tim wrote: ``` unittest{ auto p = rotate2D([0.0, 10.0], PI_2); assert(p == [-10.0, 0.0]); } ``` I suggest ``` unittest { auto p = rotate2D([0.0, 10.0], PI_2); assert(isClose(p[0], -10.0)); assert(isClose(p[1], 0.0, 0.0, 1e-6)); }

Re: Near-simplest route to learn D

2021-05-12 Thread Berni44 via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 18:37:55 UTC, NonNull wrote: Some documents/books seem to be out of date. If an intuitive person competent in several other programming languages and in abstract reasoning wanted to take the fastest route to learn pretty much the whole of D as it stands now, having

Re: question on map

2021-05-12 Thread Berni44 via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 09:52:52 UTC, Alain De Vos wrote: As oppposed to what i expect code below prints nothing nothing on the screen. What is wrong and how to fix it ? ``` import std.stdio; import std.range:iota; import std.algorithm:map; bool mywriteln(int x){ writeln(x);

Re: Remove own post from forum

2021-05-10 Thread Berni44 via Digitalmars-d-learn
On Monday, 10 May 2021 at 10:00:11 UTC, Виталий Фадеев wrote: Say, please, how to remove own post from this forum ? There's currently no way to remove or edit an existing post. ok In my opinion it is a violation of the GDPR, which gives you the right to remove such posts. GDPR applies

Re: Thoughts on Structure

2021-04-30 Thread Berni44 via Digitalmars-d-learn
On Friday, 30 April 2021 at 17:33:19 UTC, Alain De Vos wrote: An active maintainer is a living person, with a first name a last name and an email adress, who looks into issues and tries to fix them. Now go look to this page ... https://code.dlang.org/ Feel free to elaborate ... I don't

Re: dlang vs crystal-language

2021-04-28 Thread Berni44 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 05:41:45 UTC, Imperatorn wrote: Crystal has no installer for Windows Is this a strength or a weakness? (SCNR)

What are virtual functions?

2021-04-14 Thread Berni44 via Digitalmars-d-learn
I'm trying to understand, what virtual functions are. I found the [specs](https://dlang.org/spec/function.html#virtual-functions), but I can't make head or tail of it. - What is a `vtbl[]`? Obviously a function pointer table. But where to find this? The examples don't use it. Maybe something

Re: weird formattedRead

2021-04-09 Thread Berni44 via Digitalmars-d-learn
On Friday, 9 April 2021 at 16:11:26 UTC, Oleg B wrote: valid '1/1/1': 0001-Jan-01 00:00:00 <<< see here [...] Is space a special char for `formattedRead` and it simple stop parse without throwing exception if not found space (that represented in fmt string)? Have `formattedRead` any other

Re: Is this bug ? format %(%)

2021-04-07 Thread Berni44 via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 17:31:09 UTC, Paul Backus wrote: It's not your fault--this is a pretty obscure feature, and it's not documented very well. Even after you've found the correct page in the documentation (the page for `formattedWrite` [1]), you have to scroll down past multiple

Re: what exactly is string length?

2021-04-02 Thread Berni44 via Digitalmars-d-learn
On Friday, 2 April 2021 at 15:01:07 UTC, mw wrote: BTW, shall I log a writeln() improvement bug ? It's really confusing, e.g as debug print or logs. In my opinion this isn't a bug. The nulls are actually printed: ``` $> rdmd test.d | hd 61 62 63 00 00 00 36 0a 68 65 61 64 2d 61 62

Re: Need for speed

2021-04-01 Thread Berni44 via Digitalmars-d-learn
On Thursday, 1 April 2021 at 16:52:17 UTC, Nestor wrote: I was hoping to beat my dear Python and get similar results to Go, but that is not the case neither using rdmd nor running the executable generated by dmd. I am getting values between 350-380 ms, and 81ms in Python. Try using ldc2

Re: list of all defined items in a D file

2020-01-24 Thread berni44 via Digitalmars-d-learn
On Friday, 24 January 2020 at 12:22:49 UTC, Dennis wrote: You can pass the -X flag to dmd, which makes it generate a .json file describing the compiled file. Great, that's what I was looking for - although it's also good to know the __traits approach! Thanks!

list of all defined items in a D file

2020-01-23 Thread berni44 via Digitalmars-d-learn
I'd like to get a list of all items (public, package, private) that are defined in a D file. Is there a simple way, to get them?

template instantiation problems

2020-01-10 Thread berni44 via Digitalmars-d-learn
I'm trying to understand issue 17441 [1]. I reduced it (including Phobos) to the following (and added some message to point out the problem): test.d: --- alias parentOf(alias sym) = __traits(parent, sym); template packageName(alias T) { pragma(msg, "IN: ", T.stringof); static if

Re: linkererrors when reducion phobos with dustmite

2020-01-09 Thread berni44 via Digitalmars-d-learn
On Wednesday, 8 January 2020 at 19:55:57 UTC, H. S. Teoh wrote: Use dmd -i should solve the problem. Oh, thanks, now it works... (Have been using rdmd too long, so I always forget about other modules to be included.)

linkererrors when reducion phobos with dustmite

2020-01-06 Thread berni44 via Digitalmars-d-learn
As mentioned on the dustmite website [1] I copied the folder std from Phobos in a separate folder and renamed it to mystd. The I changed all occurences of std by mystd in all files. That works most of the time, but sometimes I get hundreds of linker errors I do not understand: $> dmd -main

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

2019-12-24 Thread berni44 via Digitalmars-d-learn
On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc wrote: What kind of editor/IDE are you using and which one do you like the most? I'm using sed... - no, just joking. Actually I use jed (because I did for 20 years now) with emacs keybindings in C mode, but I cannot recommend it for D. There

Re: Problem with public example in Phobos

2019-12-18 Thread berni44 via Digitalmars-d-learn
On Wednesday, 18 December 2019 at 17:57:15 UTC, Steven Schveighoffer wrote: style checker has nothing to do with buildable code. It just enforces the style follows the guidelines. It also checks, that the public unittests can be used on it's own. (Target publictests in the makefile. Didn't

Problem with public example in Phobos

2019-12-18 Thread berni44 via Digitalmars-d-learn
I thought it's a fast fix, just adding some documentation and a unittest. But when running the style checker I got into trouble. A shortend version of the problem: I added the following public unittest to writeUpToNextSpec in std.format: /// @safe unittest { import

Re: Bug or Feature: unsigned integer overflow

2019-12-14 Thread berni44 via Digitalmars-d-learn
On Saturday, 14 December 2019 at 09:33:13 UTC, Tobias Pankrath wrote: See: https://dlang.org/spec/lex.html#integerliteral What I am aiming at: Is the spec wrong or am I misunderstanding it and did this change recently? You are right. The implementation does not do what the specs tell here.

Re: Bug or Feature: unsigned integer overflow

2019-12-13 Thread berni44 via Digitalmars-d-learn
On Saturday, 14 December 2019 at 07:09:30 UTC, Tobias Pankrath wrote: void main() { auto x = 9223372036854775808; // long.max + 1 } You need to tell, that this is an unsigned long literal, else the compiler treats it as an int: void main() { auto x = 9223372036854775808UL; //

Re: Mapping float to ulong in CTFE

2019-12-13 Thread berni44 via Digitalmars-d-learn
Yeah, it worked (at least for %a): static assert(format!"%.3a"(1.0f) == "0x1.000p+0");

Re: Mapping float to ulong in CTFE

2019-12-13 Thread berni44 via Digitalmars-d-learn
On Thursday, 12 December 2019 at 19:39:16 UTC, Petar Kirov [ZombineDev] wrote: You can use a C-style pointer reinterpret cast like this: uint test(float f) { return *cast(uint*) } Make sure that source and destination types have the same size. Hey, great! :-)

Mapping float to ulong in CTFE

2019-12-12 Thread berni44 via Digitalmars-d-learn
Is it possible to get to the bits of a float in CTFE? I tried the following, but this doesn't work: ``` import std.stdio; union FloatBits { float floatValue; ulong ulongValue; } ulong test(float f) { FloatBits fb; fb.floatValue = f; return fb.ulongValue; } void main() {

opCmp with and without const

2019-12-05 Thread berni44 via Digitalmars-d-learn
In std.typecons, in Tuple there are two opCmp functions, that are almost identical; they only differ by one being const and the other not: int opCmp(R)(R rhs) if (areCompatibleTuples!(typeof(this), R, "<")) { static foreach (i; 0 .. Types.length)

Re: Confusion Concerning Numerical Equation

2019-11-16 Thread berni44 via Digitalmars-d-learn
On Saturday, 16 November 2019 at 10:01:25 UTC, Avery Stupidman wrote: assert(angleDeg(sqrt(3.0)/2.0, 1.5) == 60.0); // Fails On my computer the results are very close, that is: import std.math: nextUp; assert(nextUp(angleDeg(sqrt(3.0)/2.0, 1.5)) == 60.0); // OK On Saturday, 16 November

Re: Should I stop being interested in D language if I don't like to see template instantiation in my code?

2019-11-13 Thread berni44 via Digitalmars-d-learn
On Wednesday, 13 November 2019 at 14:23:40 UTC, mipri wrote: 3. it's very clear what's a compile-time vs. a runtime parameter to the template. At least, if one understands the difference. I remember that I was not aware of this, when I started learning D and was a lot confused by the use of

Distinguishing a pointer to a function and a closure

2019-11-11 Thread berni44 via Digitalmars-d-learn
While debugging phobos I came across some stuff I don't understand. A small example: void foo(void* p) { Object o = cast(Object) p; ClassInfo oc = typeid(o); } class Bar { void some_func(int i) {} void do_something(void delegate(int) d) { // is it possible to check

Re: Documentation: is it intentional that template constraints are displayed after the signature?

2019-11-01 Thread berni44 via Digitalmars-d-learn
On Thursday, 31 October 2019 at 13:34:35 UTC, Tobias Pankrath wrote: I was confused at first by the trailing if (!is(T == struct) && !is(T == interface) && !is(T == class) && !__traits(isStaticArray, T)); I understood your question different from what Dennis answered. At least I was

Re: Accuracy of floating point calculations

2019-10-30 Thread berni44 via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 20:15:13 UTC, kinke wrote: Note that there's at least one bugzilla for these float/double math overloads already. For a start, one could simply wrap the corresponding C functions. I guess, that this issue: https://issues.dlang.org/show_bug.cgi?id=20206 boils

Re: ddox build locally failed

2019-10-26 Thread berni44 via Digitalmars-d-learn
On Saturday, 26 October 2019 at 17:54:44 UTC, Mitacha wrote: sudo apt-get install libssl-dev That's it. Thanks. :-)

ddox build locally failed

2019-10-26 Thread berni44 via Digitalmars-d-learn
I tried to build ddox documentation locally with the command (in dlang.org): make -j3 -f posix.mak apidocs-prerelease After a while I get the message "Linking..." followed by a call of dmd with lots of parameters, among them -L-lssl and -L-lcrypto. This ends in: /usr/bin/ld: cannot find

Re: Printing floating point numbers

2019-10-25 Thread berni44 via Digitalmars-d-learn
On Friday, 25 October 2019 at 14:51:33 UTC, Yui Hosaka wrote: The outputs for your program are as follows: [...] Thanks for the output. I added it to the bug report. The internal representation of the value is correct in all versions. While the result of the direct call of snprintf always

Re: Can not understand this code.

2019-10-25 Thread berni44 via Digitalmars-d-learn
On Friday, 25 October 2019 at 06:40:19 UTC, lili wrote: Hi: What is the alias Min = xxx mean? why need defined a alias Min in Min template? ``` template Min(alias pred, Args...) if (Args.length > 0 && __traits(isTemplate, pred)) { static if (Args.length == 1) { alias Min =

Re: Printing floating point numbers

2019-10-25 Thread berni44 via Digitalmars-d-learn
On Thursday, 24 October 2019 at 20:48:02 UTC, Yui Hosaka wrote: Do you have any idea for this issue? I added a bug report: https://issues.dlang.org/show_bug.cgi?id=20320 Internally the conversation from the binary representation of the value to the printed one is done by a call to a C

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

2019-10-08 Thread berni44 via Digitalmars-d-learn
On Tuesday, 8 October 2019 at 20:37:03 UTC, dan wrote: But i would like to be able to do this without knowing the expansion of pi, or writing too much code, especially if there's some d function like writeAllDigits or something similar. You can use the property .dig to get the number of