Re: BigInt.toString

2022-08-03 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 4 August 2022 at 01:32:15 UTC, Salih Dincer wrote: I guess I wrote the following anything like that you want. ```d void main() { import std.bigint, std.string : representation; BigInt i = 1001; auto val = i.to!(dchar[]); assert(val.representation == [49, 48, 48,

Re: BigInt.toString

2022-08-03 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 4 August 2022 at 01:05:31 UTC, H. S. Teoh wrote: Don't call .toString directly. Instead, use std.format.format: ```d import std; void main() { auto x = BigInt("123123123123123123123123123123123123"); string s = format("%s", x); // this gives you the string representation

Re: BigInt.toString

2022-08-03 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 August 2022 at 00:45:44 UTC, Ruby The Roobster wrote: How exactly can one store the string representation of a BigInt? The seemingly obvious: dchar[] is necessary for my project. Assume that val is a BigInt with a value set earlier: ```d val.toString(ret, "%d"); ``` doesn't

Re: BigInt.toString

2022-08-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 12:45:44AM +, Ruby The Roobster via Digitalmars-d-learn wrote: > How exactly can one store the string representation of a BigInt? The > seemingly obvious > > ```d > //... > dchar[] ret; //dchar[] is necessary for my project > //Assume that val is a BigInt with a

Re: MMFile usage

2022-08-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 12:35:55AM +, Alex Burton via Digitalmars-d-learn wrote: > Hi, > I want to use MmFile to manage memory mapped files. I want multiple > processes to be able to read in many files using the virtual memory > system to page them in and reuse the memory. > > If I read the

BigInt.toString

2022-08-03 Thread Ruby The Roobster via Digitalmars-d-learn
How exactly can one store the string representation of a BigInt? The seemingly obvious ```d //... dchar[] ret; //dchar[] is necessary for my project //Assume that val is a BigInt with a value set earlier: val.toString(ret, "%d"); //... ``` doesn't work. I am using x86_64 windows with -m64,

MMFile usage

2022-08-03 Thread Alex Burton via Digitalmars-d-learn
Hi, I want to use MmFile to manage memory mapped files. I want multiple processes to be able to read in many files using the virtual memory system to page them in and reuse the memory. If I read the contents of the file, I can cast it to immutable and then I get segfaults when accessing the

Re: Obsecure problem 2

2022-08-03 Thread jfondren via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 19:11:51 UTC, pascal111 wrote: On Wednesday, 3 August 2022 at 18:53:35 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 18:33:37 UTC, pascal111 wrote: I changed it to "x=notfunny(x);" and has the same result. Now you are changing the value of the temporary

Re: Obsecure problem 2

2022-08-03 Thread Ruby The Roobster via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 19:11:51 UTC, pascal111 wrote: On Wednesday, 3 August 2022 at 18:53:35 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 18:33:37 UTC, pascal111 wrote: I changed it to "x=notfunny(x);" and has the same result. Now you are changing the value of the temporary

Re: Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 18:53:35 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 18:33:37 UTC, pascal111 wrote: I changed it to "x=notfunny(x);" and has the same result. Now you are changing the value of the temporary loop variable that is still immediately discarded afterwards.

Re: Obsecure problem 2

2022-08-03 Thread jfondren via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 18:33:37 UTC, pascal111 wrote: I changed it to "x=notfunny(x);" and has the same result. Now you are changing the value of the temporary loop variable that is still immediately discarded afterwards. You should return a new range that has the values you want,

Re: Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 18:25:50 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 17:33:40 UTC, pascal111 wrote: On Wednesday, 3 August 2022 at 17:09:11 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 16:59:53 UTC, pascal111 wrote: I tried to make a template that receive lambda

Re: Obsecure problem 2

2022-08-03 Thread jfondren via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 17:33:40 UTC, pascal111 wrote: On Wednesday, 3 August 2022 at 17:09:11 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 16:59:53 UTC, pascal111 wrote: I tried to make a template that receive lambda expression to apply it on a given range the user specifies,

Re: Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 17:09:11 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 16:59:53 UTC, pascal111 wrote: I tried to make a template that receive lambda expression to apply it on a given range the user specifies, but I found non-understood problem: Compare with: ```D auto

Re: Obsecure problem 2

2022-08-03 Thread jfondren via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 16:59:53 UTC, pascal111 wrote: I tried to make a template that receive lambda expression to apply it on a given range the user specifies, but I found non-understood problem: Compare with: ```D auto foo(Range)(Range range) { // remove isInputRange!T test ...

Obsecure problem 2

2022-08-03 Thread pascal111 via Digitalmars-d-learn
I tried to make a template that receive lambda expression to apply it on a given range the user specifies, but I found non-understood problem: '''D module main; import std.stdio; import std.functional; template foo(alias predicate) if (is(typeof(unaryFun!predicate))) {

Re: Choosing the correct compiler version

2022-08-03 Thread Alain De Vos via Digitalmars-d-learn
I don't know if this helps but i have to do, export CC=/usr/local/bin/gcc with ldc2. I don't know why it works with gcc but not with llvm/clang.

Re: How to cast away shared?

2022-08-03 Thread Ruby The Roobster via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 13:00:05 UTC, Paul Backus wrote: On Wednesday, 3 August 2022 at 12:50:17 UTC, Ruby The Roobster wrote: Any way to 'cast away' shared for an unknown type T? There's actually an `Unshared` template for this in `std.traits`, but for some reason it's `private`, so

Re: How to cast away shared?

2022-08-03 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 12:50:17 UTC, Ruby The Roobster wrote: Any way to 'cast away' shared for an unknown type T? There's actually an `Unshared` template for this in `std.traits`, but for some reason it's `private`, so you can't use it directly. Fortunately, it's only two lines:

How to cast away shared?

2022-08-03 Thread Ruby The Roobster via Digitalmars-d-learn
Any way to 'cast away' shared for an unknown type T?

Re: How to find all modules in a package?

2022-08-03 Thread frame via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: I want to find out all public functions in all modules in a package. Can I do that at compile time? You can do something like that: ```d static foreach (sym; __traits(allMembers, mixin("std.string"))) { pragma(msg, sym.stringof);

Re: How to find all modules in a package?

2022-08-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: I want to find out all public functions in all modules in a package. Can I do that at compile time? No, D packages are not closed; anyone can add new modules to them at any time.

Re: How to find all modules in a package?

2022-08-03 Thread Piotr Mitana via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: I want to find out all public functions in all modules in a package. Can I do that at compile time? I think it's not possible.

Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64

2022-08-03 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 09:39:36 UTC, ryuukk_ wrote: Does adding ```-m64``` work I'm using macOS so I don't think that applies. But no, it doesn't do anything for me. Thanks, --anonymouse

Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64

2022-08-03 Thread ryuukk_ via Digitalmars-d-learn
Does adding ```-m64``` work

Re: A look inside "filter" function defintion

2022-08-03 Thread novice2 via Digitalmars-d-learn
leyts try very rough simlified concept: template itself - is compile-time program (parameterizable), it can generate some code for you. template instantiation (like "calling") with "!" - instruct compiler to "start this compile-time program here with this parameters".

Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64

2022-08-03 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 05:04:08 UTC, H. S. Teoh wrote: On Wed, Aug 03, 2022 at 04:28:57AM +, anonymouse via Digitalmars-d-learn wrote: How do I go about tracking down what's causing the following error: ``` Undefined symbols for architecture x86_64: