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

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 lan

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

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

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 palet

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 informati

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 compiles

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 p

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 std.

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

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

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 the

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 tho

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: 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." https://dlang.org/p

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 fr

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

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 (MyObjec

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 a

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

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

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

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 onlinea

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 st

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: 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: 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: 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: GC-less string formatting

2020-10-19 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: 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 regi

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 ParameterWithMe

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

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

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

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, but

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 onlinea

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 it

Re: Why can I call a function with mismatched parameter type?

2020-12-11 Thread rikki cattermole via Digitalmars-d-learn
string is not a built in type. It is an alias defined by druntime. https://github.com/dlang/druntime/blob/master/src/object.d#L35 int on the other hand is defined by the compiler. It understands it. Further, when the parameter name is not provided it will infer based upon what is passed in. In

Re: Why can I call a function with mismatched parameter type?

2020-12-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/12/2020 12:32 AM, rikki cattermole wrote: Further, when the parameter name is not provided it will infer based upon what is passed in. In effect it is templated. What I meant was: the type is inferred if you only provide a single identifier in a parameter.

Re: MonoTimeImpl!(ClockType.normal) failed to get the frequency of the system's monotonic clock.

2020-12-13 Thread rikki cattermole via Digitalmars-d-learn
Did you initialize the D runtime before you called the D code? (assuming C main).

Re: uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread rikki cattermole via Digitalmars-d-learn
On 14/12/2020 9:56 AM, kdevel wrote: On Sunday, 13 December 2020 at 20:25:06 UTC, KapyoniK wrote: Is it really a bug ? \0 truncates the string, as mentionned on this page : https://en.wikipedia.org/wiki/Null-terminated_string I thought the D runtime is written in D (with D strings)?!? Strin

Re: Range of dub package versions

2020-12-28 Thread rikki cattermole via Digitalmars-d-learn
$ dub upgrade https://dub.pm/commandline.html#upgrade dub.selections.json hasn't been deleted/upgraded so the versions would have gotten pinned to a known good state. Unless you change the version invalidating it, it most likely won't upgrade by itself.

Re: D string to C struct fixed-size array

2021-01-03 Thread rikki cattermole via Digitalmars-d-learn
import std; void main() { int[] a = [1, 2, 3, 4, 5]; int[3] b; b[0 .. 3] = a[1 .. 4]; b.writeln; } Same principle, just remember to null terminate after slicing your dynamic array and assigning it to your static array.

Re: D string to C struct fixed-size array

2021-01-03 Thread rikki cattermole via Digitalmars-d-learn
Your definition of Image is probably wrong. You may have missed a pointer (8 bytes).

Re: properly passing strings to functions? (C++ vs D)

2021-01-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/01/2021 3:12 AM, zack wrote: A beginner question: How to pass strings properly to functions in D? Is there any allocation going on if just use a function as "myPrint"? In C++ I have often seen calls where one just passes a reference/const reference to a string to avoid allocation. C++:

Re: How to debug D on Linux

2021-01-13 Thread Rikki Cattermole via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 13:47:55 UTC, Roguish wrote: On Wednesday, 13 January 2021 at 13:30:48 UTC, Roguish wrote: Anything else I need to know when debugging on Linux, without an IDE? One specific question I have is: what's the difference between -g and -debug and -d-debug? From L

Re: reference counting resources but NOT memory

2021-01-16 Thread rikki cattermole via Digitalmars-d-learn
What you are describing sounds like regular reference counting. All resources (i.e. windows) are pinned somewhere in memory. Its just that you have to use special API's to destroy them rather than free.

Re: which free operating systems have a gtkd package?

2021-01-22 Thread rikki cattermole via Digitalmars-d-learn
https://d-apt.sourceforge.io/ Or you could use dub and not worry about where its installed. https://github.com/gtkd-developers/GtkD/wiki/Hello-World-Example-on-Ubuntu-19.10-(Linux)

Re: Initializing D runtime and executing module and TLS ctors for D libraries

2021-01-27 Thread rikki cattermole via Digitalmars-d-learn
On 28/01/2021 1:16 PM, tsbockman wrote: The documentation build on dlang.org is broken. Check the source code or Adam D. Ruppe's dpldocs.info for the complete documentation: http://dpldocs.info/experimental-docs/core.thread.osthread.html Fixed: https://issues.dlang.org/show_bug.cgi?id=21309

Re: core.atomic for ldc.

2021-01-31 Thread rikki cattermole via Digitalmars-d-learn
The only difference between dmd, ldc and gdc (in effect) is the backend. While druntime and Phobos will be patched for other platform targets, over all its the same library. The same goes for core.atomic. You should not need to know that it has been patched. If you can call it and it gives you

Re: Minimize GC memory footprint

2021-02-06 Thread rikki cattermole via Digitalmars-d-learn
On 06/02/2021 3:32 PM, frame wrote: On Friday, 5 February 2021 at 22:46:05 UTC, Bastiaan Veelo wrote: ?? Do you mean no collections happen? 32bit GC should just work. No, it doesn't - this code fails on memory allocation and works fine with -m64 switch: import std.stdio; import core.memor

Re: Minimize GC memory footprint

2021-02-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/02/2021 12:38 AM, Siemargl wrote: On Saturday, 6 February 2021 at 11:20:18 UTC, Imperatorn wrote: On Saturday, 6 February 2021 at 09:42:38 UTC, rikki cattermole wrote: On 06/02/2021 3:32 PM, frame wrote:  [...] This won't do anything.  [...] Don't forget to stdout.flush; Otherwise

Re: Minimize GC memory footprint

2021-02-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/02/2021 4:22 AM, frame wrote: On Saturday, 6 February 2021 at 13:30:03 UTC, rikki cattermole wrote: Okay, its still seeing something is alive then. That's why I used the scope guard. I know it shouldn't have any effect but I want to give the GC an extra hint ;) The GC shouldn't be aw

Re: Are there any containers that go with allocators?

2021-02-09 Thread rikki cattermole via Digitalmars-d-learn
https://github.com/dlang-community/containers It uses the older design for allocators (dependency).

Re: Class instance alignment

2021-02-20 Thread rikki cattermole via Digitalmars-d-learn
On 20/02/2021 8:13 PM, tsbockman wrote: Well, that's just another reason not to use the GC for my current project, then: I'm using 256-bit AVX vectors extensively. You can still use the GC. You just can't use it to allocate the classes you care about. https://dlang.org/phobos/core_memory.html

Re: How can I make this work?

2021-02-28 Thread rikki cattermole via Digitalmars-d-learn
On 28/02/2021 8:05 PM, Jack wrote: int[] arr = [1, 2, 3]; size_t l = cast(size_t)arr.ptr; Okay, so far so good int[] a = cast(int[]) cast(void*) l; Umm, you haven't specified a length? int[] a = (cast(int*)l)[0 .. 3]; If the callback is being called (in effect under the current stack fram

Re: How can I make this work?

2021-02-28 Thread rikki cattermole via Digitalmars-d-learn
On 28/02/2021 11:05 PM, Max Haughton wrote: Do the windows APIs expect the length in memory rather than as a parameter? This sounds like its being sent via a user field to be passed to a callback. I.e. event loop for a window. In this sort of case you only get one parameter on the callback an

Re: Unexpected threads observed before main()

2021-02-28 Thread rikki cattermole via Digitalmars-d-learn
Do you still get them when you call your app like this? ./app --DRT-gcopt=parallel:0

Re: Unexpected threads observed before main()

2021-03-01 Thread rikki cattermole via Digitalmars-d-learn
On 01/03/2021 8:02 PM, Keivan Shah wrote: If possible, Can you also help me understand that why are the threads not despawned once the GC is done collecting in this example? There was a PR about this ages ago. But one thing to consider is that keeping threads around not doing anything doesn't

Re: How to handle exceptions right?

2021-03-08 Thread rikki cattermole via Digitalmars-d-learn
https://github.com/dlang/phobos/blob/master/std/socket.d#L190 Might be of some use to you

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread rikki cattermole via Digitalmars-d-learn
Pipe it to grep should work | grep -v "__D2"

Re: can't link a code, is it a bug or my fault?

2021-03-11 Thread rikki cattermole via Digitalmars-d-learn
Try it with: -allinst It may just be deciding a template instance isn't required.

Re: running a d compiler on the Mac Mini with an M1 chip

2021-03-26 Thread rikki cattermole via Digitalmars-d-learn
On 27/03/2021 10:51 AM, dan wrote: Are there any d compilers that run natively on the Mac Mini with an M1 chip? If so, does anybody here have any experience with them that can be shared? If not, and your machine is a mac mini, how would you go about programming in d on it? TIA for any info!

Re: what exactly is string length?

2021-04-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2021 5:32 PM, mw wrote: --- import std; import std.conv : text; void main() {    char[6] s;    s = "abc";    writeln(s, s.length);  // abc6, ok it's the static array's length    string t = text("head-", s, "-tail");    writeln(t, t.length);  // head-abc-tail16, why? assert(t[9]

Re: what exactly is string length?

2021-04-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2021 5:38 PM, mw wrote: On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole wrote: On 02/04/2021 5:32 PM, mw wrote: --- import std; import std.conv : text; void main() {     char[6] s;     s = "abc";     writeln(s, s.length);  // abc6, ok it's the static array's length     str

Re: what exactly is string length?

2021-04-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2021 5:51 PM, mw wrote: Then how can I construct `t`? to make this assertion true:    assert(t == "head-abc-tail");  // failed! Slice it. string t = text("head-", s[0 .. 3], "-tail"); http://ddili.org/ders/d.en/slices.html

Re: what exactly is string length?

2021-04-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2021 6:10 PM, Computermatronic wrote: On Friday, 2 April 2021 at 05:02:52 UTC, mw wrote: Ahh, I got what I see (from writeln) is not what get string here ;-) And I just tried: string t = text("head-", strip(s), "-tail"); It's the same behavior. So how can I trim the leading & trai

Re: Check attribute against value

2021-04-02 Thread rikki cattermole via Digitalmars-d-learn
"Whether the attributes are values or types is up to the user, and whether later attributes accumulate or override earlier ones is also up to how the user interprets them." This doesn't explain it well, but you were adding types as attributes on to those symbols. Not struct instances.

Re: Deprecation message when assigning Nullable values to an associative array.

2021-04-03 Thread rikki cattermole via Digitalmars-d-learn
Nullable has an alias this which has been deprecated. It is due for removal (the alias this). You can remove it manually from your copy of phobos source. Otherwise you'll just have to wait until it is removed upstream. (deprecation are not errors, so you can ignore them).

Re: Deprecation message when assigning Nullable values to an associative array.

2021-04-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/04/2021 10:58 PM, rikki cattermole wrote: Nullable has an alias this which has been deprecated. It is due for removal (the alias this). You can remove it manually from your copy of phobos source. Otherwise you'll just have to wait until it is removed upstream. (deprecation are not err

Re: Extern/scope issue

2021-04-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/04/2021 11:01 PM, DLearner wrote: 'Testmain' imports module 'testmod'. Both are shown below. I expected 1,1,2,2. I got 1,0,2,1 - which speaks to scope/extern misunderstanding Any ideas? Best regards Testmain: int xvar; TLS variable with D mangling, not a c global. import testmod; voi

Re: Extern/scope issue

2021-04-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/04/2021 11:17 PM, DLearner wrote: On Saturday, 3 April 2021 at 10:05:45 UTC, rikki cattermole wrote: On 03/04/2021 11:01 PM, DLearner wrote: [...] TLS variable with D mangling, not a c global.  [...] That is a regular variable. Setting the calling convention/mangling like that doe

Re: Extern/scope issue

2021-04-03 Thread rikki cattermole via Digitalmars-d-learn
--- main.d module main; extern(C) __gshared int foo; import std; void main() { import foo : func; func; writeln(foo); } --- foo.d module foo; extern extern(C) __gshared int foo; void func() { foo++; } The __gshared is irrelevant to it working between modules, but it is rel

Re: Extern/scope issue

2021-04-03 Thread rikki cattermole via Digitalmars-d-learn
On 04/04/2021 2:34 AM, DLearner wrote: However, changing extern(C) to extern(D) causes linker failures. To me, that is bizarre. extern(D) sets the ABI AND mangling. D mangling incorporates things like the module name.

Re: Extern/scope issue

2021-04-03 Thread rikki cattermole via Digitalmars-d-learn
On 04/04/2021 2:48 AM, DLearner wrote: On Saturday, 3 April 2021 at 13:38:25 UTC, rikki cattermole wrote: On 04/04/2021 2:34 AM, DLearner wrote: However, changing extern(C) to extern(D) causes linker failures. To me, that is bizarre. extern(D) sets the ABI AND mangling. D mangling incorpo

Re: dub commands do not run correctly.

2021-04-10 Thread rikki cattermole via Digitalmars-d-learn
On 10/04/2021 11:44 PM, Alain De Vos wrote: In order to run commands correctly I have to put soft links : I.e. dfmt -> /home/x/.dub/packages/dfmt-0.13.4/dfmt/bin/dfmt or, dscanner -> /home/x/.dub/packages/dscanner-0.11.0/dscanner/bin/dscanner Then ./dfmt or ./dscanner run fine. I use freebsd as

Re: dub commands do not run correctly.

2021-04-10 Thread rikki cattermole via Digitalmars-d-learn
dub run dfmt -- ./app.d You passed "./app.d" to dub, not dfmt.

Re: dlang opengl / gl / glu /glut library.

2021-04-21 Thread rikki cattermole via Digitalmars-d-learn
On 22/04/2021 7:51 AM, Alain De Vos wrote: import bindc.opengl; bindbc

Re: Thread local variables in betterC

2021-05-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/05/2021 6:41 AM, Blatnik wrote: Do thread local variables work in -betterC? Or maybe it's better to ask are they _supposed_ to work in -betterC? No. It is tied to druntime. I.e. on Linux it calls __tls_get_addr to get the address.

Re: Can rdmd (under Windows 10) use linker other than Optlink?

2021-05-14 Thread rikki cattermole via Digitalmars-d-learn
On 15/05/2021 9:42 AM, DLearner wrote: I am getting 'Error 42: Symbol Undefined' while testing some (fairly) complex imports. There was a reference in January to an Optlink bug that seemed like it could be responsible. If rdmd can use another linker (and one was recommended), I might be a

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

2021-06-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/06/2021 2:47 PM, someone wrote: 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 attri

Re: Unittests not firing?

2021-06-11 Thread rikki cattermole via Digitalmars-d-learn
rdmd -main -unittest file.d ```d import std.stdio; unittest { writeln("first"); } unittest { writeln("second"); assert(0); } ``` Output: ``` first second onlineapp.d(11): [unittest] unittest failure 1/1 modules FAILED unittests ``` The first assert to execute should kill the re

<    1   2   3   4   5   6   7   8   9   10   >