Re: Pass enum variable as const ref arg

2020-12-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/12/2020 2:42 AM, Andrey wrote: Hm, you mean that enum variable is not a real variable? It is not a variable. It is a constant that cannot be changed and does not exist in the executable. I thought that to make CT variable you should mark it as enum (in c++ as constexpr). How to do

Re: Pass enum variable as const ref arg

2020-12-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/12/2020 1:54 AM, Andrey wrote: Hello, void test(const ref string[3] qazzz) { qazzz.writeln; } void main() {     enum string[3] value = ["qwer", "ggg", "v"]; That is a compile time constant (remove the enum).     test(value); } Gives errors: onlineapp.d(26): Error: function

Re: Local libraries/packages with dub: How?

2020-11-30 Thread rikki cattermole via Digitalmars-d-learn
On 01/12/2020 7:39 PM, z wrote: On Tuesday, 1 December 2020 at 04:50:03 UTC, rikki cattermole wrote: ... What puzzles me is that the dependencies are indeed declared, but "dub describe" refuses to recognize the dependencies and "dub build" fails. "dub list" does recognize the root folder,

Re: Local libraries/packages with dub: How?

2020-11-30 Thread rikki cattermole via Digitalmars-d-learn
dub add-local, adds a directory as a known package that it can use as a dependency (or to be executed). You need to specify in the package that depends on the dependency what dependencies you have. I.e. See the dependencies key: { "name": "myproject", "description": "A

Re: why is "hello".writeln considered bad?

2020-11-20 Thread rikki cattermole via Digitalmars-d-learn
I was the person who wrote that example. It was just an example to show how it can be used. I would not write a function call like that when using a literal. As Mike said, its all up to personal preference.

Re: betterC question

2020-11-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/11/2020 1:11 PM, Dibyendu Majumdar wrote: On Thursday, 19 November 2020 at 00:08:59 UTC, Adam D. Ruppe wrote: On Thursday, 19 November 2020 at 00:07:12 UTC, Dibyendu Majumdar wrote: int function() fp = test; This tries to *call* the function test and assign its return value to fp.

Re: toStringz lifetime

2020-11-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/11/2020 2:58 PM, Ali Çehreli wrote: Does the D GC know the complete function call stack of the C program all the way up from 'main'? Is there the concept of "bottom of the stack" or does the D GC can only know the value of the stack pointer at the time rt_init() was called. If the

Re: Empty functions

2020-10-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/10/2020 10:06 PM, Jan Hönig wrote: On Thursday, 29 October 2020 at 09:01:12 UTC, Jan Hönig wrote: This would mean, that this one should work as well. It does not work as I intended, as `() => {}` has not the return type of `void`. (I don't know how to print: `ReturnType!(() => {})`)

Re: Empty functions

2020-10-29 Thread rikki cattermole via Digitalmars-d-learn
(Params){ FunctionBody; } Rule: ref|opt ParameterWithMemberAttributes FunctionLiteralBody https://dlang.org/spec/expression.html#function_literals void function() Is a type https://dlang.org/spec/type.html#delegates () => {} Is actually: () => Expression Rule: ref|opt

Re: toStringz lifetime

2020-10-25 Thread rikki cattermole via Digitalmars-d-learn
On 25/10/2020 11:03 PM, Ali Çehreli wrote: Does the GC see that local variable 'name' that is on the C side? What I don't know is whether the GC is aware only of the stack frames of D functions or the entire thread, which would include the C caller's 'name'. The thread stack frame that is

Re: GC-less string formatting

2020-10-20 Thread rikki cattermole via Digitalmars-d-learn
https://dlang.org/phobos/std_format.html#formattedWrite Uses GC for exception (so cannot be @nogc yet), but otherwise it should be GC free.

Re: winapi, dll

2020-10-15 Thread rikki cattermole via Digitalmars-d-learn
On 16/10/2020 9:13 AM, Atmosfear wrote: I'm a newby. Can you show me an example? In which module is it? You can search for it on Github and it'll show up. https://github.com/dlang/druntime/search?q=QueryPerformanceCounter

Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.

2020-10-02 Thread rikki cattermole via Digitalmars-d-learn
On 02/10/2020 9:33 PM, Imperatorn wrote: Did you create a D-partition just for D. Pro You can mount directories as a drive on Windows. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/subst

Re: dub sub-projects

2020-09-20 Thread rikki cattermole via Digitalmars-d-learn
On 21/09/2020 6:24 AM, Vladimirs Nordholm wrote: I am unsure what the dub file would look like. I read that there is something called "subPackages", but in my mind I see them as dependencies. Is "subPackages" the right approach here? Yes but no. Normally all of these (what appear to be small

Re: Installing D on Fresh Windows 10 machine is a pain

2020-08-28 Thread rikki cattermole via Digitalmars-d-learn
On 28/08/2020 3:59 AM, Jesse Phillips wrote: DMD installer still is unable to find "VS installed" One of the reasons for this is that the environment variables have not been updated. You need to restart to do this.

Re: Could someone calrify reserving and collecting memory via the Garbabe Collector ?

2020-08-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/08/2020 5:12 AM, wjoe wrote: There's core.memory.GC.reserve which requests memory from the OS. Basically pre-allocating memory for the GC heap. Is the GC heap shared among all threads ? That is up to the GC implementation. And is it correct that even if I call GC.disable, the GC may

Re: Template error with gdc-10 but not with latest dmd and ldc

2020-07-26 Thread rikki cattermole via Digitalmars-d-learn
Old frontend: Up to 2.060 : Failure with output: onlineapp.d(2): Error: valid attribute identifiers are @property, @safe, @trusted, @system, @disable not @nogc 2.061 to 2.065.0: Failure with output: - onlineapp.d(2): Error: user defined attributes cannot appear as postfixes

Re: Why is typeof(readln) -> void?

2020-07-18 Thread rikki cattermole via Digitalmars-d-learn
On 18/07/2020 9:14 PM, blizzard wrote: Can anybody explain the difference between readln() and readln? I read somewhere that the () were optional, so why this difference? The brackets are optional when calling a function. You are not calling a function if you wrap it in typeof. "The

Re: Calling a C function whose name is a D reserved word or keyword

2020-07-06 Thread rikki cattermole via Digitalmars-d-learn
https://dlang.org/spec/pragma.html#mangle pragma(mangle, "body") extern(C) void body_func();

Re: Translating C headers to D: How do I compile it?

2020-06-27 Thread rikki cattermole via Digitalmars-d-learn
On 28/06/2020 4:59 PM, Kirill wrote: module something; extern(C) int add(int a, int b); Compile as static library some.c, add to command line of dmd. Should be this simple more or less, depending on compilers and target involved.

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread rikki cattermole via Digitalmars-d-learn
if (Child child = cast(Child)parent) { assert(child !is null); }

Re: any chance to get it working on windows xp?

2020-05-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/05/2020 12:51 AM, a beginner wrote: @rikki cattermole Dmd and ldc's codegen haven't stood still for 10 years. They both will be emitting instructions your cpu cannot handle. Hence crashes. So... was I wrong to assume it generates code for the cpu it's running on (a P4 Northwood in my

Re: any chance to get it working on windows xp?

2020-05-17 Thread rikki cattermole via Digitalmars-d-learn
It isn't just about the OS. Dmd and ldc's codegen haven't stood still for 10 years. They both will be emitting instructions your cpu cannot handle. Hence crashes.

Re: Building Win32 application via dub

2020-04-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/04/2020 10:27 PM, Sam E. wrote: To be honest, I haven't yet found the way to switch between -m32 and -m64 (or other) via dub :) $ dub build --arch=x86 $ dub build --arch=x86_64

Re: To get memory from another process.

2020-04-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/04/2020 7:42 AM, Dennis wrote: On Thursday, 9 April 2020 at 19:27:16 UTC, Quantium wrote: I see this code imports drivers and does it depend on processor architecture? Would it work only on 64-bit or 32-bit or some special architechtures? kernel32.dll and psapi.dll should be present on

Re: Dub will not load bindbc-harfbuzz

2020-04-09 Thread rikki cattermole via Digitalmars-d-learn
How old is your build of dub? "betterC" build option was introduced in 1.20.0

Re: To get memory from another process.

2020-04-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/04/2020 4:25 AM, Net wrote: On Tuesday, 7 April 2020 at 21:20:28 UTC, Quantium wrote: Could you advise me how to do these steps on D? Which libs should I import? 1. My programm gets a path to exe file 2. My programm starts that exe file and writes into it 2 commands 3. Programm gets

Re: Issues creating a dynamic libary with dub

2020-03-24 Thread rikki cattermole via Digitalmars-d-learn
When I see -fPIC I think something is wrong with your compiler+runtime setup. Use -v to see the commands dub is using. This should not be dub related.

Re: can a unittest read main()'s args?

2020-03-22 Thread rikki cattermole via Digitalmars-d-learn
On 22/03/2020 8:57 PM, mark wrote: I have a module with a unittest { ... } block. However, when I run dub test sometimes I want to output some extra data when the test runs. At the moment I control this by using an environment variable, but I wondered if it was possible to pass a command line

Re: Pattern matching via switch?

2020-03-17 Thread rikki cattermole via Digitalmars-d-learn
On 18/03/2020 12:59 AM, Steven Schveighoffer wrote: I think he's looking for object pattern matching. i.e. you give it an Object, and it runs a block of code based on the derived type. In case this syntax is unknown: if (MyObject1 myObject = cast(MyObject1)obj) { ... } else if

Re: string to char* in betterC

2020-03-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/03/2020 5:07 AM, Abby wrote: What is the proper way to get char* from string which is used in c functions? toStringz does returns: /usr/include/dmd/phobos/std/array.d(965,49): Error: TypeInfo cannot be used with -betterC and I think string.ptr is not safe because it's not zero

Re: D create many thread

2020-02-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/02/2020 8:53 AM, uranuz wrote: Is it also possible to set some custom thread name for GC threads in order to be distinguishable from other threads in utilities like `htop`? It would be handy... https://dlang.org/phobos/core_thread_osthread.html#.Thread.name.2

Re: Algebraic changing type when in associative array

2020-02-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/02/2020 2:11 AM, Paul Backus wrote: On Tuesday, 4 February 2020 at 11:45:50 UTC, rous wrote: I'm defining an Algebraic type like this: alias Expr = Algebraic!(This[char], string, int); However, when I create an Expr from an associative array of chars and Exprs, the Exprs seem to change

Re: Algebraic changing type when in associative array

2020-02-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/02/2020 12:55 AM, rous wrote: On Tuesday, 4 February 2020 at 11:47:49 UTC, rikki cattermole wrote: It did not change type. "Algebraic data type restricted to a closed set of possible types. It's an alias for VariantN with an appropriately-constructed maximum size."

Re: Algebraic changing type when in associative array

2020-02-04 Thread rikki cattermole via Digitalmars-d-learn
It did not change type. "Algebraic data type restricted to a closed set of possible types. It's an alias for VariantN with an appropriately-constructed maximum size." https://dlang.org/phobos/std_variant.html#.Algebraic

Re: range algorithms on container class

2020-01-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/01/2020 6:28 PM, Alex Burton wrote: I am writing a specialised container class, and want to make it work like a normal array with range functions. After some struggle, I look at the code for std.container.array and see this comment : When using `Array` with range-based functions like

Re: Project setup for DUB

2020-01-01 Thread rikki cattermole via Digitalmars-d-learn
On 01/01/2020 9:11 PM, Ankush Bhardwaj wrote: I am now stuck here not knowing what should I do next or how should I compile. Compile what? You successfully compiled and ran your dub build. Please note the default action is to run, so using `dub` by itself is equivalent to `dub run`. Hence

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

2019-12-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/12/2019 9:19 PM, Piotr Mitana wrote: On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc 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? IntelliJ IDEA CE with this

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

2019-12-21 Thread rikki cattermole via Digitalmars-d-learn
On 22/12/2019 7:11 PM, moth wrote: hi all. been learning d for the last few years but suddenly realised... when i use this code: writeln('♥'); the output displayed on the windows command line is "ÔÖÑ" [it works fine when piped directly into a text file, however]. i've looked about in this

Re: How bundles a Dlang application and all its dependencies into a single .exe package?

2019-12-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/12/2019 9:05 AM, Marcone wrote: My program have Qt5 GUI that use dlls, icons, pictures, etc. How bundles a Dlang application and all its dependencies into a single .exe package? Placing all your assets into an exe is usually done if the exe itself is self extracting (and doesn't link

Re: Leak-detection of references to scoped class instances

2019-11-24 Thread rikki cattermole via Digitalmars-d-learn
"Allocates a class object right inside the current scope, therefore avoiding the overhead of new. This facility is unsafe; it is the responsibility of the user to not escape a reference to the object outside the scope." https://dlang.org/phobos/std_typecons.html#.scoped

Re: How polymorphism work in D?

2019-11-05 Thread rikki cattermole via Digitalmars-d-learn
On 06/11/2019 6:43 PM, OiseuKodeur wrote: I have this ``` import std.stdio : writeln; abstract class Foo { } class Bar : Foo {     float value;     this(float t_value) { value = t_value; } } class Baz : Foo {     string name;     this(string t_name) { name = t_name; } } void main() {

Re: File I/O performance pitfalls

2019-10-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/10/2019 2:27 PM, 9898287 wrote: Hi I want to find out what's causing my file writes to be so slow. I'm setting up buffer and locking the file and writing them to the file. $ cat d.d && ldc2 -O5  d.d && time ./d >> /dev/null You probably want -O3 not -O5. void main() {     import

Re: struct Foo may not define both a rvalue constructor and a copy constructor

2019-10-16 Thread rikki cattermole via Digitalmars-d-learn
On 17/10/2019 4:29 AM, drug wrote: struct Foo {     this(ref const(Foo) other) {}     this(const(Foo) other) {} } I'm trying to update dmd version and starting from 2.086 my code doesn't compile due to the error above. What is the reason of that? Copy constructors were added (sort of like

Re: ld errors in osx Catalina

2019-10-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/10/2019 11:33 PM, David Briant wrote: I've accidentally upgraded to Catalina - a little earlier than planned as I had hoped not to be trail blazing! My problem is this, in a bash shell and a new directory when I run $ dub init ... answering the questions that dub asks $ dub dmd

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

2019-10-03 Thread rikki cattermole via Digitalmars-d-learn
On 04/10/2019 3:13 AM, IGotD- wrote: According to the GC documentation this code snippet char* p = new char[10]; char* q = p + 6; // ok q = p + 11;  // error: undefined behavior q = p - 1;   // error: undefined behavior suggests that char *p is really a "fat pointer" with size

Re: Indexed graphics for retro engine?

2019-09-19 Thread rikki cattermole via Digitalmars-d-learn
On 20/09/2019 8:47 AM, Shadowblitz16 wrote: On Thursday, 19 September 2019 at 19:16:03 UTC, Mike Parker wrote: On Thursday, 19 September 2019 at 18:25:05 UTC, Shadowblitz16 wrote: I wanted to do 4bpp 16 color graphics. and I didn't want to load anything unnecessary in the image like the

Re: Input engine

2019-09-15 Thread rikki cattermole via Digitalmars-d-learn
On 15/09/2019 12:16 PM, Joel wrote: What is a good keyboard input handler or so? Just need one that picks up that a key is down, but not like a word processor. Are you referring to when you hold down a key and multiple characters gets added to the text area? If so, this feature is called

Re: Slicing upward

2019-09-15 Thread rikki cattermole via Digitalmars-d-learn
On 15/09/2019 5:06 AM, Brett wrote: On Saturday, 14 September 2019 at 11:39:21 UTC, rikki cattermole wrote: On 14/09/2019 11:34 PM, Brett wrote: I have an algorithm that is most efficiently implement by taking an array and slicing it upward, meaning removing the leading elements. Because the

Re: Slicing upward

2019-09-14 Thread rikki cattermole via Digitalmars-d-learn
On 14/09/2019 11:34 PM, Brett wrote: I have an algorithm that is most efficiently implement by taking an array and slicing it upward, meaning removing the leading elements. Because the algorithm is complex(deterministic but chaotic) and deals with multiple arrays it is difficult to

Re: Linking to -framework on MacOS

2019-09-04 Thread rikki cattermole via Digitalmars-d-learn
Four years ago, I was linking against Cocoa via: "lflags-osx": ["/System/Library/Frameworks/Cocoa.framework/Cocoa"], I don't know if this will help you or not.

Re: How to run the dub bundle with dmd

2019-08-10 Thread rikki cattermole via Digitalmars-d-learn
This is a crazy question but is your Windows install 64bit?

Re: Help me decide D or C

2019-07-31 Thread rikki cattermole via Digitalmars-d-learn
Whatever direction you choose to go, you should have a good community available to help you out. For D there is the Discord (or IRC, but I think Discord would be more suited to you) https://discord.gg/3vFMag7 And there is a Facebook group which I'm apart of which is decent (caters to all

Re: Meaning of Scoped! ??

2019-07-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/07/2019 9:33 PM, Ron Tarrant wrote: Some things are almost impossible to research. For instance, in the GtkD wrapper code—specifically the Widget.d file—the following function definition appears: gulong addOnDraw(bool delegate(Scoped!Context, Widget) dlg, ConnectFlags

Re: Building GDC with auto-generated header files

2019-07-29 Thread rikki cattermole via Digitalmars-d-learn
On 30/07/2019 4:11 AM, Eduard Staniloiu wrote: Cheers, everybody I'm working on this as part of my GSoC project [0]. I'm working on building gdc with the auto-generated `frontend.h` [1], but I'm having some issues There are functions in dmd that don't have an `extern (C)` or `extern (C++)`

Re: vibe / self contained standalone executable?

2019-07-28 Thread rikki cattermole via Digitalmars-d-learn
On 29/07/2019 2:42 AM, Robert M. Münch wrote: On 2019-07-28 14:14:06 +, Sebastiaan Koppe said: I am using https://dlang.org/spec/expression.html#import_expressions for text files. Don't know if it works on binary files as well. And this works than good together with the vibe framework?

Re: Is betterC affect to compile time?

2019-07-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/07/2019 12:30 AM, Oleg B wrote: On Thursday, 25 July 2019 at 12:20:04 UTC, Mike Franklin wrote: If you read the documentation for betterC (https://dlang.org/spec/betterc.html#consequences) you'll see that there are features of the D language which are not supported. Therefore,

Re: Any easy way to check if an object have inherited an interface?

2019-07-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/07/2019 9:34 AM, solidstate1991 wrote: It seems that I've to write my own function that searches in the given object's classinfo.interfaces since I couldn't find anything related in Phobos. if (Foo foo = cast(Bar)bar) { }

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/07/2019 12:58 AM, drug wrote: 22.07.2019 15:53, rikki cattermole пишет: https://godbolt.org/z/EtZLG0 hmm, in short - this is my local problem? That is not how I would describe it. I would describe it as IEEE-754 doing what IEEE-754 is good at. But my point is, you can get the

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/07/2019 12:49 AM, drug wrote: I have almost identical (I believe it at least) implementation (D and C++) of the same algorithm that uses Kalman filtering. These implementations though show different results (least significant digits). Before I start investigating I would like to ask if

Re: Wrong vtable for COM interfaces that don't inherit IUnknown

2019-07-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/07/2019 5:44 PM, Kagamin wrote: On Tuesday, 16 July 2019 at 01:38:49 UTC, evilrat wrote: Also from what I see MS done this intentionally, means they either no longer loves COM or there was some other good reason. Primary consumer of COM interfaces is Visual Basic. It was really only

Re: Windows segfault, need brief help

2019-07-12 Thread rikki cattermole via Digitalmars-d-learn
dmd v2.082 cannot reproduce Needs to be tested on something newer perhaps?

Re: Where can find dmd back-end source code.

2019-06-17 Thread rikki cattermole via Digitalmars-d-learn
You found it. https://github.com/dlang/dmd/tree/master/src/dmd/backend Generates x86 and x86_64.

Re: How does this template work?

2019-06-16 Thread rikki cattermole via Digitalmars-d-learn
On 17/06/2019 3:11 AM, Robert M. Münch wrote: How does the observerObject Template and function work? I'm struggling because both use the same name and how is the template parameter R deduced/where is it coming from? Looks like it's somehow implicitly deduced. class ObserverObject(R,

Re: Suggest aesthetic way to Naming a module or a package with illegal lexical D lang keywords

2019-06-16 Thread rikki cattermole via Digitalmars-d-learn
The style guide has an opinion about this (you don't have to follow it). https://dlang.org/dstyle.html#naming_keywords

Re: need article: How is working D-GC?

2019-06-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/06/2019 11:40 AM, Rémy Mouëza wrote: If I recall correctly, there is (or was) also a precise GC in the work, but I currently don't have any links to it. Its already in. Its a modification on the conservative GC to make it more efficient.

Re: Using python in D

2019-06-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/06/2019 3:54 PM, rnd wrote: Edit: I tried above D program and got following error: core.exception.AssertError@/home/abcde/.dub/packages/pyd-0.10.5/pyd/infrastructure/pyd/embedded.d(53): python not initialized ??:? _d_assert_msg [0x5562d3f3c466]

Re: 'version'-based code selection

2019-05-31 Thread rikki cattermole via Digitalmars-d-learn
On 01/06/2019 3:59 PM, Yatheendra wrote: Hi people. The 'version' keyword sounds like a fantastic capability, but how far does DMD take it (and does GDC take it equally far)? This is not a "D Improvement Proposal", I am just asking how it is now. GDC, LDC and DMD all share the same

Re: get executable version

2019-05-31 Thread rikki cattermole via Digitalmars-d-learn
On 01/06/2019 7:07 AM, Machine Code wrote: is there something on std library or package on dub to get a executable version on windows? just in case I don't need to dig into winapi. Like C#'s: FileVersionInfo.GetVersionInfo(path).FileVersion

Re: Using D's precise GC when running an app with DUB

2019-05-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/05/2019 3:03 AM, Per Nordlöw wrote: On Thursday, 23 May 2019 at 15:02:12 UTC, rikki cattermole wrote: And if I want to set this in a dub.sdl? No can do. There is meant to be a way to set it in D however. But I have heard mixed results (not that I've tried it). Should be as easy as   

Re: Using D's precise GC when running an app with DUB

2019-05-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/05/2019 2:58 AM, Per Nordlöw wrote: On Thursday, 23 May 2019 at 14:51:41 UTC, rikki cattermole wrote: dub run --compiler=dmd --build=unittest -- --DRT-gcopt=gc:precise Thanks! And if I want to set this in a dub.sdl? No can do. There is meant to be a way to set it in D however. But I

Re: Using D's precise GC when running an app with DUB

2019-05-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/05/2019 3:01 AM, Per Nordlöw wrote: On Thursday, 23 May 2019 at 14:51:41 UTC, rikki cattermole wrote: dub run --compiler=dmd --build=unittest -- --DRT-gcopt=gc:precise Hmm, the flag doesn't propagate to dmd when compiling in verbose mode via -v as     dub run -v --compiler=dmd

Re: Using D's precise GC when running an app with DUB

2019-05-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/05/2019 2:50 AM, Per Nordlöw wrote: How do I specify a druntime flag such as     --DRT-gcopt=gc:precise when running with dub as     dub run --compiler=dmd --build=unittest dub run --compiler=dmd --build=unittest -- --DRT-gcopt=gc:precise

Re: Performance of tables slower than built in?

2019-05-21 Thread rikki cattermole via Digitalmars-d-learn
On 22/05/2019 12:22 PM, JS wrote: I am trying to create some fast sin, sinc, and exponential routines to speed up some code by using tables... but it seems it's slower than the function itself?!? The code below uses matplotlibd but is not necessary. The timing code is lower. Ideally I'd

Re: Does slicing have an effect?

2019-05-21 Thread rikki cattermole via Digitalmars-d-learn
On 22/05/2019 8:31 AM, Dennis wrote: I was replacing a memcpy with a slice assignment and accidentally used == instead of =. Usually the compiler protects me from mistakes like that: ``` int[4] a; a == a; ``` Error: a == a has no effect However, because I was using slices it didn't: ```

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

2019-05-20 Thread rikki cattermole via Digitalmars-d-learn
On 20/05/2019 11:10 PM, Boqsc 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. https://wiki.dlang.org/Review_Queue Since std.decimal

Re: mixing (else) static if inadvertently with else if

2019-05-18 Thread rikki cattermole via Digitalmars-d-learn
Works: --- import std.stdio; void main() { func!true(false); func!false(false); func!false(true); } void func(bool A)(bool b) { static if (A) { writeln("a"); } else if (b) { writeln("b"); } else { writeln("c"); } } --- This works because

Re: windowsx.h

2019-05-12 Thread rikki cattermole via Digitalmars-d-learn
On 13/05/2019 5:00 AM, Robert M. Münch wrote: On 2019-05-12 10:33:16 +, Robert M. Münch said: Is there any reason why windowsx.h seems to be missing from core.sys.windows? Using DStep I now converted windowsx.h into windowsx.d Is creating a pull-request the correct way to submit it to

Re: Any full feature xml library available?

2019-05-02 Thread rikki cattermole via Digitalmars-d-learn
On 03/05/2019 4:23 AM, Russel Winder wrote: On Fri, 2019-05-03 at 03:50 +1200, rikki cattermole via Digitalmars-d- learn wrote: On 03/05/2019 3:36 AM, Russel Winder wrote: […] libxml2 is definitely usable from Python, it must be usable from D. Of course, I am assuming libxml2 has

Re: Any full feature xml library available?

2019-05-02 Thread rikki cattermole via Digitalmars-d-learn
On 03/05/2019 3:36 AM, Russel Winder wrote: On Thu, 2019-05-02 at 02:11 +1200, rikki cattermole via Digitalmars-d- learn wrote: […] It does not. Those features come under the big bad guys feature list. Gonna have to go to C for it. Surely that means you can use Python, Rust, C++, or D

Re: Any full feature xml library available?

2019-05-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/05/2019 2:04 AM, Domain wrote: On Wednesday, 1 May 2019 at 13:57:04 UTC, bachmeier wrote: On Wednesday, 1 May 2019 at 13:54:08 UTC, Domain wrote: I need a xml library which support document entity or xinclude. The xml may like this: ]> http://www.w3.org/2001/XInclude;>        

Re: srand time error uint/long

2019-04-29 Thread rikki cattermole via Digitalmars-d-learn
float f = uniform01(); Its already initialized on module load. If you do want to custom seed it, you'll probably want to cast the seed to uint instead and have your own instance of the random number generator.

Re: Does new X() return a pointer or not?

2019-04-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/04/2019 2:34 AM, faissaloo wrote: Are objects automatically assumed to be pointers? It is a reference. Which is a fancy way of saying pointer under the hood. Just don't do pointer arithmetic with it ;) Object* means a pointer to a class object reference. Which isn't what you were

Re: Poor regex performance?

2019-04-04 Thread rikki cattermole via Digitalmars-d-learn
If you need performance use ldc not dmd (assumed). LLVM has many factors better code optimizes than dmd does.

Re: DMD: can't get extern __gshared to work right (vs. LDC)

2019-02-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/02/2019 6:26 AM, DanielG wrote: In the meantime, while I'm waiting for this bug to be noticed by anybody with the skills to address it, what would be the most elegant way of working around it? Obviously I could do a: version(Windows) {   export extern __gshared ... } else {   extern

Re: DMD: can't get extern __gshared to work right (vs. LDC)

2019-02-08 Thread rikki cattermole via Digitalmars-d-learn
On 08/02/2019 9:14 PM, DanielG wrote: On Friday, 8 February 2019 at 07:52:26 UTC, Kagamin wrote: AFAIK, export attribute doesn't do much on posix platforms. I created a minimal example and it definitely segfaults at runtime in the presence of "export" (on Mac, haven't tested linux). So it's

Re: Status of BetterC

2019-01-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/01/2019 3:12 AM, Pavel Vozenilek wrote: I am interested in viability of using BetterC (and only BetterC) for a project. 1. Is BetterC supported by GDC and LDC compilers? LDC yes, dunno about GDC but it'll depend upon the version. 2. Is there debugger/editor/IDE support? Not

Re: Syntax for Pointer to Class

2019-01-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/01/2019 9:52 AM, Q. Schroll wrote:     C* ptr = &[ new C(...) ][0]; C* ptr = [ new C(...) ].ptr; Should work.

Re: How is this code supposed to work?

2019-01-25 Thread rikki cattermole via Digitalmars-d-learn
On 25/01/2019 10:34 PM, AndreasDavour wrote: How am I supposed to use that??   auto point3 = getResponse!Point!int("What's the point? "); auto point3 = getResponse!(Point!int)("What's the point? ");   auto point4 = getResponse!Point!int("What's the point? ");   writeln("Distance: ",

Re: Compiling to 68K processor (Maybe GDC?)

2019-01-19 Thread rikki cattermole via Digitalmars-d-learn
On 20/01/2019 1:38 AM, Edgar Vivar wrote: Hi, I have a project aiming to old 68K processor. While I don't think DMD would be able for this on the other hand I think GDC can, am I right? If yes would be any restriction of features to be used? Or the compiler would be smart enough to handle

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-15 Thread rikki cattermole via Digitalmars-d-learn
On 16/01/2019 1:05 AM, John Burton wrote: On Tuesday, 15 January 2019 at 11:26:50 UTC, rikki cattermole wrote: Longer term, you're better off with the builder. Thanks for your reply. But what is the builder? https://en.wikipedia.org/wiki/Builder_pattern One of the few OOP design patterns

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-15 Thread rikki cattermole via Digitalmars-d-learn
Longer term, you're better off with the builder. Even with named parameters (2 DIP's are in the queue for adding it). Creating windows is a very complex task that can balloon in scope. Being able to hide it away in a separate type can be quite desirable if you want your windowing library to be

Re: Destructor for struct invoked many times

2019-01-15 Thread rikki cattermole via Digitalmars-d-learn
Because you passed it by value to writeln, which goes on to pass it to many other functions.

Re: Reversing a string

2019-01-11 Thread rikki cattermole via Digitalmars-d-learn
So strings in D are Unicode. This is both a great thing and a horrible thing. To reverse a Unicode string correctly you need to take into account BiDi and graphemes, in other words it gets rather complex. However I suspect that this isn't what you want. Now a (w/d)string is defined as: alias

Re: Temporary @trusted scope

2018-12-19 Thread rikki cattermole via Digitalmars-d-learn
On 20/12/2018 5:02 AM, Jonathan M Davis wrote: On Wednesday, December 19, 2018 1:19:42 AM MST rikki cattermole via Digitalmars-d-learn wrote: On 19/12/2018 7:11 PM, Jonathan M Davis wrote: Really? I would have thought that that would be a pretty obvious optimization (especially if inlining

Re: Mixin operator 'if' directly

2018-12-19 Thread rikki cattermole via Digitalmars-d-learn
Mixin templates don't work on statements only declarations like structs.

Re: Temporary @trusted scope

2018-12-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/12/2018 7:11 PM, Jonathan M Davis wrote: Really? I would have thought that that would be a pretty obvious optimization (especially if inlining is enabled). Assembly doesn't lie.

Re: Temporary @trusted scope

2018-12-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/12/2018 1:34 AM, Per Nordlöw wrote: On Tuesday, 18 December 2018 at 10:42:51 UTC, Jonathan M Davis wrote: Unfortunately, D does not currently have a way to do that. Only functions can be marked with @trusted. However, the typical approach to this problem is to use a lambda, which is more

Re: is(ElementType!(char[2]) == dchar - why?

2018-12-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/12/2018 6:51 AM, Denis Feklushkin wrote: import std.stdio; import std.range.primitives; void main() {     writeln(     typeid(ElementType!(char[2]))     );     static assert(is(ElementType!(char[2]) == dchar)); // why? } ? https://run.dlang.io/is/Q74yHm Because docs:

Re: Writing Program Without main Function

2018-12-07 Thread rikki cattermole via Digitalmars-d-learn
There is always a main function. It doesn't matter in which module its in or language. It just has to exist.

  1   2   3   4   5   6   7   8   9   >