Re: Exercise at end of Ch. 56 of "Programming in D"

2022-08-20 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 15 August 2022 at 03:19:43 UTC, johntp wrote: Your solution worked. I guess it is a little unnatural to ignore the color. I tried overriding the toHash() of Point, but I don't know enough D to get it to work. I wonder if that could be a solution. Depends on what you're trying

Re: Is there any implementation of a 128bit integer?

2022-07-10 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 8 July 2022 at 15:32:44 UTC, Rob T wrote: https://forum.dlang.org/post/mailman.10914.1566237225.29801.digitalmars-d-le...@puremagic.com In case someone comes across this old thread https://dlang.org/phobos/core_int128.html There was a discussion on this not long ago. Walter tried

Re: Infinite fibonacci sequence, lazy take first 42 values

2022-04-21 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 21 April 2022 at 04:36:13 UTC, Salih Dincer wrote: My favorite is the struct range. Because it is more understandable and personalized. Moreover, you can limit it without using ```take()```. And it's inherently lazy, so no extra processing/calculation other than what's

Re: Beginner memory question.

2022-04-19 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 16 April 2022 at 20:48:15 UTC, Adam Ruppe wrote: On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote: Is virtual memory entering into the equation? Probably. Memory allocated doesn't physically exist until written to a lot of the time. This might be very much an OS

Re: Can Enums be integral types?

2022-04-19 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 13:20:21 UTC, Bastiaan Veelo wrote: There is nothing that requires enum values to be unique, though: ```d import std; void main() { enum E {Zero = 0, One = 0, Two = 0} writeln(E.Two); // Zero! } ``` True, but if you want it be useful they really need to be

Re: Can Enums be integral types?

2022-04-18 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 17 April 2022 at 18:25:32 UTC, Bastiaan Veelo wrote: On Saturday, 16 April 2022 at 11:39:01 UTC, Manfred Nowak wrote: In the specs(17) about enums the word "integral" has no match. But because the default basetype is `int`, which is an integral type, enums might be integral types

Re: How to implement this?

2022-04-07 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 8 April 2022 at 04:54:35 UTC, Era Scarecrow wrote: Maybe it should be `cast(A*) `? Confusing HTML entities bit on here. Probably just ignore it. Maybe you are doing it backwards. What if you had ```d struct B { A* a; } A[] arraylist; ``` then in the init append a new item to

Re: How to implement this?

2022-04-07 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 8 April 2022 at 04:31:45 UTC, Elvis Zhou wrote: B b; init(\); structs ~= cast(A*)\ //Error: copying `cast(A*)\& b` into allocated memory escapes a reference to local variable `b` Maybe it should be `cast(A*) \`?

Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 23 March 2022 at 00:51:42 UTC, Era Scarecrow wrote: On Tuesday, 22 March 2022 at 21:23:43 UTC, H. S. Teoh wrote: We already have this: import std.conv : to; int x; long y; y = x.to!long; // equivalent to straight assignment / cast x =

Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 21:23:43 UTC, H. S. Teoh wrote: On Tue, Mar 22, 2022 at 09:11 PM, Era Scarecrow wrote: [...] I'd almost wish D had a more lenient mode and would do automatic down-casting, then complain if it *would* have failed to downcast data at runtime. [...] We already

Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 18:47:19 UTC, Ali Çehreli wrote: On 3/22/22 11:28, Era Scarecrow wrote: > So when should you use size_t? I use size_t for anything that is related to count, index, etc. However, this is a contested topic because size_t is unsigned. I don't see a problem with

Re: Basic question about size_t and ulong

2022-03-22 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 18 March 2022 at 23:01:05 UTC, Ali Çehreli wrote: P.S. On a related note, I used to make the mistake of using size_t for file offsets as well. That is a mistake because even on a 32-bit system (or build), file sizes can be larger than uint.max. So, the correct type is long for

Re: Nested Classes with inheritance

2022-03-20 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 20 March 2022 at 05:44:44 UTC, Salih Dincer wrote: On Sunday, 20 March 2022 at 01:28:44 UTC, Era Scarecrow wrote: Inheritance and Polymorphism is one of the hardest things to grasp mostly because examples they give in other books of 'objects' is so far unrelated to software that it

Re: Nested Classes with inheritance

2022-03-19 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 19 March 2022 at 12:23:02 UTC, user1234 wrote: I think OP is learning OOP. His error looks like that for the least. True. Looking at the code it shouldn't spaghetti in on itself infinitely and is basically clean in his intent. Inheritance and Polymorphism is one of the hardest

Re: Nested Classes with inheritance

2022-03-18 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 19 March 2022 at 00:16:48 UTC, user1234 wrote: That crashes because of the creation of `Bar b` member, which itself has a Bar b member, which itself... Mhmm... So There's Foo with Bar b, which has Bar b which has Bar b which... just keeps going over and over again. It appears

Re: How to exclude function from being imported in D language?

2022-03-17 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 8 March 2022 at 22:28:27 UTC, bauss wrote: What D just needs is a way to specify the entry point, in which it just defaults to the first main function found, but could be any function given. Which is similar to what Java does. When i was first learning Java in a company i would

Re: static init c struct with array filed

2022-03-16 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 11:27:20 UTC, user1234 wrote: assuming the c library takes by reference My experience all arrays are effectively just pointers, and the brackets/length is only really applicable to stack allocated fixed length allocations. In my own C projects i always used

Re: Strange behavior of iota

2022-02-15 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: On Tuesday, 15 February 2022 at 22:02:13 UTC, Adam D Ruppe wrote: for(a = v.length; a > cast(size_t) -1, a += -1) After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say that iota's behavior

Re: How to verify DMD download with GPG?

2022-02-14 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 8 February 2022 at 10:17:19 UTC, Ola Fosheim Grøstad wrote: I do like the idea that a hacker cannot change the signature file if gaining access to the web/file hosts, but how to verify it in secure way? For Linux sources there's MD5 and SHA-1 hashes i believe. If you have two or

Re: how to handle very large array?

2022-02-12 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 10 February 2022 at 01:43:54 UTC, H. S. Teoh wrote: On Thu, Feb 10, 2022 at 01:32:00AM +, MichaelBi via Digitalmars-d-learn wrote: thanks, very helpful! i am using a assocArray now... Are you sure that's what you need? Depends. if you do say TYPE[long/int] then you have

Re: How to work with hashmap from memutils properly?

2022-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 11 February 2022 at 02:43:24 UTC, Siarhei Siamashka wrote: Though this strange benchmark is testing performance of an LRU with ... wait for it ... 10 elements, which makes using hashmap/dict/AA a completely ridiculous idea. Hmmm... if it's static data i can see maybe a enum

Re: number ranges

2022-01-18 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 17 January 2022 at 22:28:10 UTC, H. S. Teoh wrote: This will immediately make whoever reads the code (i.e., myself after 2 months :D) wonder, "why +1?" And the answer will become clear and enlightenment ensues. ;-) In those cases i find myself rewriting said code. Generally to

Re: Throw stack trace from program kill

2022-01-16 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 16 January 2022 at 18:03:53 UTC, Paul Backus wrote: On POSIX, you can use the `sigaction` function to install a signal handler for `SIGINT`, the signal generated by CTRL+C. To terminate the program with a stack trace, simply have the signal handler `throw` an `Error`. I never

Re: Dynamic array or not

2022-01-16 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 16 January 2022 at 15:32:41 UTC, Salih Dincer wrote: If count is not equal to 8 I get weird results! The reason of course, is the free(): // [93947717336544, 1, 2, 3, 4, 5, 6] I wonder if you're seeing something you're not suppose to as part of the internals; Typically malloc for

Re: mixin does not work as expected

2022-01-05 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 5 January 2022 at 08:40:15 UTC, rempas wrote: I'm trying to use mixins and enums to "expand" code in place but the results are not what I expected and I'm getting an weird error. I have created the smallest possible example to reproduce the error and it is the following: Back

Re: print ubyte[] as (ascii) string

2021-12-30 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 30 December 2021 at 09:34:27 UTC, eugene wrote: The buffer contains (ascii) string terminated with '\n'. In order to print it not as an array of numbers (buf is 1024 bytes long), but as usual string I do Few years ago i asked a similar question, not to do UTF-8 but to do Ascii.

Re: AA and struct with const member

2021-12-29 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 29 December 2021 at 01:11:13 UTC, Stanislav Blinov wrote: Because opIndexAssign cannot distinguish at compile time between initialization and assignment: ```d Stuff[Key] aa; aa[key] = Stuff(args); // ostensibly, initialization aa[key] = otherStuff; // assignment to existing

Re: AA and struct with const member

2021-12-28 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 07:51:04 UTC, frame wrote: On Tuesday, 28 December 2021 at 01:45:42 UTC, Era Scarecrow wrote: Success! So i summarize, either work with a pointer, or drop the const... Of course casting the const away was the first thing I did but I think this is not

Re: AA and struct with const member

2021-12-27 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 27 December 2021 at 19:38:38 UTC, frame wrote: I feel stupid right now: One cannot assign a struct that contains const member to AA? Error: cannot modify struct instance ... of type ... because it contains `const` or `immutable` members This is considered a modification? ```d

Re: How to print unicode characters (no library)?

2021-12-27 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 27 December 2021 at 07:12:24 UTC, rempas wrote: On Sunday, 26 December 2021 at 21:22:42 UTC, Adam Ruppe wrote: write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure out. Oh, so it was as I expected :P

Re: First time using Parallel

2021-12-26 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 26 December 2021 at 15:36:54 UTC, Bastiaan Veelo wrote: On Sunday, 26 December 2021 at 15:20:09 UTC, Bastiaan Veelo wrote: So if you use `workerLocalStorage` ... you'll get your output in order without sorting. Scratch that, I misunderstood the example. It doesn't solve ordering.

Re: Double bracket "{{" for scoping static foreach is no longer part of D

2021-12-26 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 22 December 2021 at 16:30:06 UTC, data pulverizer wrote: On Wednesday, 22 December 2021 at 16:10:42 UTC, Adam D Ruppe wrote: So OUTSIDE a function, static foreach() {{ }} is illegal because a plain {} is illegal outside a function. But INSIDE a function, static foreach() {{ }}

Re: First time using Parallel

2021-12-26 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 26 December 2021 at 11:24:54 UTC, rikki cattermole wrote: I would start by removing the use of stdout in your loop kernel - I'm not familiar with what you are calculating, but if you can basically have the (parallel) loop operate from (say) one array directly into another then you

First time using Parallel

2021-12-25 Thread Era Scarecrow via Digitalmars-d-learn
This is curious. I was up for trying to parallelize my code, specifically having a block of code calculate some polynomials (*Related to Reed Solomon stuff*). So I cracked open std.parallel and looked over how I would manage this all. To my surprise I found ParallelForEach, which gives the

Re: DConf 2020 Canceled

2020-03-07 Thread Era Scarecrow via Digitalmars-d-announce
On Saturday, 7 March 2020 at 20:37:32 UTC, Mike Parker wrote: I really wish I didn't have to make this announcement, but in light of the COVID-19 outbreak and with an abundance of caution, the D Language Foundation and Symmetry Investments have agreed to cancel DConf 2020. From what i've

Re: budding d programmer seeking guidance for an issue

2019-12-28 Thread Era Scarecrow via Digitalmars-d-debugger
On Saturday, 28 December 2019 at 20:05:46 UTC, Yash Bhambhu wrote: I am working on issue #20412 which is std.range.pustd.outputrange.put() misbehave s when defined for void[] misbehaves when OutputRange.put(void[] exists) In the case where void[] is passed, could it cast to ubyte[]?

Re: struct inside struct: Is there a way to call a function of the outside struct from the inner struct?

2019-07-06 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 6 July 2019 at 12:33:00 UTC, berni wrote: Now I found this: https://forum.dlang.org/thread/eobdqkkczquxoepst...@forum.dlang.org Seems to be intentional, that this doesn't work. In my case I'm able to move d() into the outer struct... You'll need a pointer to the outer struct,

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 5 July 2019 at 16:25:10 UTC, Nick Treleaven wrote: Yes, I was wondering why the compiler doesn't statically allocate it automatically as an optimization. Which i would think it could, but silently adds .dup to the end as it points to a unnamed memory block of N size. Or if it's

Re: Bitfields

2019-05-21 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 17:16:05 UTC, Russel Winder wrote: As far as I can see std.bitmanip only caters for 8, 16, 32, and 64 bit long bitfields. I worked on/with bitfields in the past, the limit sizes is more or less for natural int types that D supports. However this limitation is

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

2019-05-20 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 20 May 2019 at 12:50:29 UTC, Simen Kjærås wrote: If you're worried that $92_233_720_368_547_758.07 (long.max) is not enough money for your game, I'd note that the entire current world economy is about a thousandth of that. Even so, there's std.bigint.BigInt, which has no set limit,

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

2019-05-20 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 20 May 2019 at 11:50:57 UTC, Dennis wrote: For a simple game, I think it's the easiest to just store an integer of cents (or the lowest amount of currency possible). Back in 2003 i did this very thing for when creating my C program for suggesting and helping with credit card

Re: Hookable Swap

2019-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 20 May 2019 at 02:18:51 UTC, Era Scarecrow wrote: Here's some outputs if you are interested Noticing how Heapify moves a large portion of areas more or less in their location, doing heapify before binary insertion sort lowers how much moving goes on quite a bit. Doing 2 heapify's

Re: Hookable Swap

2019-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 19 May 2019 at 06:13:13 UTC, Era Scarecrow wrote: Making a struct type/array that visually outputs and displays compares/mutations of a type. While using the library sorting functions (which relies on std.algorithm.mutation.swap Well been having fun with sorting and more of this;

Re: Same code different behaviour in debug & release mode?

2019-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 19 May 2019 at 17:55:10 UTC, Robert M. Münch wrote: It seems that the debugger has quite some problem when the code was compiled with optimization and debug-information. I remember having similar problems in a C program years ago, ended up just releasing the code unoptimized and

Hookable Swap

2019-05-19 Thread Era Scarecrow via Digitalmars-d-learn
Making a struct type/array that visually outputs and displays compares/mutations of a type. While using the library sorting functions (which relies on std.algorithm.mutation.swap) it doesn't call opAssign and doesn't pass through the struct. (which also changes the indexes which it shouldn't).

Re: Random thought: Alternative stuct

2018-09-03 Thread Era Scarecrow via Digitalmars-d
On Tuesday, 4 September 2018 at 03:38:41 UTC, Nick Sabalausky (Abscissa) wrote: We have classes and structs: Classes: - Default Storage: GC Heap - Indirection Overhead: Yes - Semantics: Reference - Passed By: Copying the Data's Address Structs: - Default Storage: Stack - Indirection Overhead:

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: atan should work out to only be a few instructions (inline assembly) from what I've looked at in the source. Also you should post the code you used for each. Should be 3-4 instructions. Load input to the FPU (Optional?

Re: Caesar Cipher

2018-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 11 February 2018 at 18:01:20 UTC, Mario wrote: char[] encrypt(char[] input, char shift) { auto result = input.dup; result[] += shift; return result; } What's wrong? I mean, I know that z is being converted into a symbol, but how should I fix this? If you take Z (25)

Re: ESR on post-C landscape

2017-11-14 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 06:32:55 UTC, lobo wrote: And I fixed it all right – took me two weeks of struggle. After which I swore a mighty oath never to go near C++ again. ...[snip]" Reminds me of the last time I touched C++. A friend wanted help with the Unreal Engine. While

Re: BinaryHeap as member

2017-11-13 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 13 November 2017 at 16:26:20 UTC, balddenimhero wrote: In the course of writing a minimal example I removed more than necessary in the previous pastebin (the passed IntOrder has not even been used). Thus here is the corrected one: https://pastebin.com/SKae08GT. I'm trying to port

Re: find difference between two struct instances.

2017-07-21 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 21 July 2017 at 21:03:22 UTC, FoxyBrown wrote: Is there a way to easily find the differences between to struct instances? I would like to report only the differences e.g., writeln(s1 - s2); prints only what is different between s1 and s2. This is entirely dependent on the

Re: How to init immutable static array?

2017-07-18 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 07:30:30 UTC, Era Scarecrow wrote: my_array[i]=some calculations(based on constants and n) i meant: tmp[i]=some calculations(based on constants and n)

Re: How to init immutable static array?

2017-07-18 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 07:20:48 UTC, Miguel L wrote: Hi, I need help again. I have an immutable static array and i need to initialize its contents inside a for loop. Something like this: void f(int n)() { immutable float[n] my_array; for(int i=0;i

Re: How to get the address of a static struct?

2017-07-09 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 10 July 2017 at 03:48:17 UTC, FoxyBrown wrote: static struct S auto s = // ?!?!?! invalid because S is a struct, but... basically s = S. So S.x = s.x and s.a = S.a; Why do I have to do this? Static has a different meaning for struct. More or less it means it won't have access

Re: CTFE output is kind of weired

2017-07-08 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 8 July 2017 at 21:29:10 UTC, Andre Pany wrote: app.d(17):called from here: test("1234\x0a5678\x0a") I wrote the source code on windows with a source file with \r\n file endings. But the console output has only the character X0a. In addition not the content of tmp is shown

Re: Funny issue with casting double to ulong

2017-07-04 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 12:32:26 UTC, Patrick Schluter wrote: In times of lore, BCD floats were very common. The Sharp Pocket Computer used a BCD float format and writing machine code on them confronts one with the format. The TI-99/4A home computer also used a BCD float format in its Basic

Re: how to disable all default N-argument constructors for a struct?

2017-07-03 Thread Era Scarecrow via Digitalmars-d
On Tuesday, 4 July 2017 at 00:46:36 UTC, Timothee Cour wrote: How would I disable the following? ``` auto a1=A(1); auto a2=A(1, "b"); struct A{ int a; string b; // @disable default constructors with N(N>=1) arguments } ``` I'd like to force the user to set fields explicitly, so as to

Re: Funny issue with casting double to ulong

2017-07-02 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: 6.251 has no perfect double representation. It's real value is: I almost wonder if a BCD, fixed length or alternative for floating point should be an option... Either library, or a hook to change how the FPU works since doubles are

Re: Win10 defender still sees dmd.exe and rdmd.exe as malicious

2017-06-25 Thread Era Scarecrow via Digitalmars-d
On Monday, 26 June 2017 at 01:55:56 UTC, Matt wrote: New user here. I know the first 5 minutes experience is important, just to note that rdmd.exe and executables created with dmd.exe are flagged as malicious by windows defender. It's easy to create an exception in the windows defender

Re: What is your favorite D feature?

2017-06-22 Thread Era Scarecrow via Digitalmars-d
On Thursday, 22 June 2017 at 00:48:25 UTC, Seb wrote: I would love to hear about your favorite feature(s) in D. Arrays include length along with the pointer. Very easy built-in array support with foreach Ranges, that don't treat their input types as 'pointers' and get all levels of

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-12 Thread Era Scarecrow via Digitalmars-d
On Saturday, 10 June 2017 at 19:40:47 UTC, Andrei Alexandrescu wrote: That's cool as long as the assembler is guarded by version(X_86) and has a portable alternative. Where's the code? Should i do a pull request and push it under std.experimental? Also if it's going to get renamed to a

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-12 Thread Era Scarecrow via Digitalmars-d
On Monday, 12 June 2017 at 13:41:36 UTC, deadalnix wrote: You misunderstood. We need cent/ucent supported by the compiler to get to larger integral types efficiently. There are no ways around it. There are a ton of operations such as the X86 MUL which are able to produce a large multiplication

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-11 Thread Era Scarecrow via Digitalmars-d
On Sunday, 11 June 2017 at 21:52:40 UTC, Era Scarecrow wrote: Doing a 10240bit int I ran though 1,000 factorials in 6 seconds (this includes printing the values out). I got to about 400 in 16 minutes using the generic code. Got the compatible/generic code to run far faster, about 7 times

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-11 Thread Era Scarecrow via Digitalmars-d
On Sunday, 11 June 2017 at 21:52:40 UTC, Era Scarecrow wrote: Also got Cent working (mostly). It's complete, more or less now. I just a matter of filling in any missing methods that I haven't programmed for, and probably adding filler/forwarding functions from ScaledInt to UScaledInt.

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-11 Thread Era Scarecrow via Digitalmars-d
On Sunday, 11 June 2017 at 18:01:41 UTC, Era Scarecrow wrote: And what timing, I just finished getting it working with assembly and compatible versions. Seems 5x slower rather than the dreaded 50, but that's from testing factorial up to 100 (200ms vs 1,200ms). Doing a 10240bit int I ran

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-11 Thread Era Scarecrow via Digitalmars-d
On Sunday, 11 June 2017 at 18:01:41 UTC, Era Scarecrow wrote: Anyways, here's how it is currently, most features are avaliable, need more tests and find occurrences where it doesn't work. I should probably mention that's only for UCent, Cent isn't fully tested or implemented yet.

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-11 Thread Era Scarecrow via Digitalmars-d
On Sunday, 11 June 2017 at 08:52:37 UTC, deadalnix wrote: I ended up doing my own. There are just no way to do it well without cent/ucent . Weka is running into the same problem for error correction. And what timing, I just finished getting it working with assembly and compatible versions.

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-10 Thread Era Scarecrow via Digitalmars-d
On Saturday, 10 June 2017 at 19:40:47 UTC, Andrei Alexandrescu wrote: On 6/10/17 3:28 PM, Era Scarecrow wrote: Got a possible one. My implementation is heavy on assembly language to take advantage of x86 features That's cool as long as the assembler is guarded by version(X_86) and has a

Re: Is there a good lib out there to handle large integer of know size ?

2017-06-10 Thread Era Scarecrow via Digitalmars-d
On Saturday, 9 January 2016 at 20:28:26 UTC, Andrei Alexandrescu wrote: Who can champion ONE fixed large integer library for Phobos? -- Andrei Got a possible one. My implementation is heavy on assembly language to take advantage of x86 features (like the carry flag, and giving you 64 &

Re: Is D slow?

2017-06-09 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 9 June 2017 at 18:32:06 UTC, Steven Schveighoffer wrote: Wow, so that's how D code would look like if it were C++ :) When dipping my toes into C++ to do a quicksort algorithm, I quickly got annoyed I'd have to create all the individual comparison functions rather than just one

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 8 June 2017 at 02:19:15 UTC, Andrew Edwards wrote: Pretty funny. But seriously, this is something that should just work. There is now to layers of indirection to achieve what I used to do quite naturally in the language. Hmmm while working on my recent sudoku solver using

Re: rawRead using a struct with variable leght

2017-06-07 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 7 June 2017 at 18:31:41 UTC, H. S. Teoh wrote: "Structs" with variable size fields have no direct equivalent in D's type system, so you'll probably have a hard time mapping this directly. What you *could* do, though, is to load the data into a ubyte[] buffer, then create a

Re: C++17 cannot beat D surely

2017-06-06 Thread Era Scarecrow via Digitalmars-d
On Saturday, 3 June 2017 at 19:12:46 UTC, Steven Schveighoffer wrote: I'd say this deserves a blog post but it would be too short. Actually i wouldn't mind a vlog or some short presentations on a variety of subjects. Maybe even continuations of presentations that could have been at the

Re: rawRead using a struct with variable leght

2017-06-05 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 5 June 2017 at 16:04:28 UTC, ade90036 wrote: Unfortunately the struct doesn't know at compile time what the size of the constant_pool array, or at-least was not able to specify it dynamically. It also won't know ahead of time how many fields, methods or attributes you have

Re: Mixin in Inline Assembly

2017-06-02 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 1 June 2017 at 12:00:45 UTC, Era Scarecrow wrote: So why is the offset off by 14h (20 bytes)? It's not like we need a to set a ptr first. Go figure i probably found a bug... Well as a side note a simple yet not happy workaround is making a new array slice of the memory and

Re: "Lazy" initialization of structs

2017-06-01 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 1 June 2017 at 12:04:05 UTC, Daniel Tan Fook Hao wrote: If I'm reading this right, in the former, the struct is created when the function is called in run-time, and the type is then inferred after that? I don't really understand the behavior behind this. The only difference

Re: Mixin in Inline Assembly

2017-06-01 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 23 May 2017 at 03:33:38 UTC, Era Scarecrow wrote: From what I'm seeing, it should be 8, 0ch, 10h, then 14h, all positive. I'm really scratching my head why I'm having this issue... What am i missing here? More experiments and i think it comes down to static arrays. The

Re: [OT] I-frame cutting in H.264

2017-05-30 Thread Era Scarecrow via Digitalmars-d
On Tuesday, 30 May 2017 at 11:32:21 UTC, Marco Leise wrote: Ok, but even then your source material would ideally have to be encoded with the same codec and parameters. A different resolution would not work, while a change in frame rate is tolerable. I agree, however when VirtualDub barfs,

Re: purity question

2017-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 29 May 2017 at 01:12:53 UTC, Era Scarecrow wrote: ... Hmm didn't notice the post had split. Otherwise i wouldn't have replied... That and thinking about the GC state (outside of allocating memory)...

Re: purity question

2017-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 28 May 2017 at 23:49:16 UTC, Brad Roberts wrote: // do something arbitrarily complex with s that doesn't touch globals or change global state except possibly state of the heap or gc Sounds like the basic definition of pure to me; At least in regards to D. Memory allocation

Re: Any video editing folks n da house?

2017-05-27 Thread Era Scarecrow via Digitalmars-d
On Saturday, 27 May 2017 at 22:28:13 UTC, Nick Sabalausky (Abscissa) wrote: Good point. Although, AIUI, that does leave you limited to cutting only on full frames, not on the delta frames. Sometimes that's an issue, sometimes it isn't. Well you can cut anywhere (on the tail end anyways),

Re: Any video editing folks n da house?

2017-05-27 Thread Era Scarecrow via Digitalmars-d
On Wednesday, 24 May 2017 at 10:04:03 UTC, Wulfklaue wrote: Working on a compressed video to create another compressed video, simply result in lower quality video ( and less professional looking ). Only if you have to recompress it. Some tools like VirutalDub allow you to chop and copy

Re: Sudoku Py / C++11 / D?

2017-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 15 August 2012 at 20:13:10 UTC, Era Scarecrow wrote: On Wednesday, 15 August 2012 at 15:39:26 UTC, ixid wrote: Could you supply your code? Which one are you using as the hardest? If you're solving the 1400 second one in 12 seconds that's very impressive, I can't get it below 240

Re: Sorted sequences

2017-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 25 May 2017 at 10:39:01 UTC, Russel Winder wrote: C++ has std:priority_queue as a wrapper around a heap to create a sorted queue. Am I right in thinking that D has no direct equivalent, that you have to build you own wrapper around a heap? Do you even need a wrapper? Glancing

Re: Mixin in Inline Assembly

2017-05-22 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 11 January 2017 at 17:32:35 UTC, Era Scarecrow wrote: Still I think I'll impliment my own version and then if it's faster I'll submit it. Decided I'd give my hand at writing a 'ScaledInt' which is intended to basically allow any larger unsigned type. Coming across some

Re: No tempFile() in std.file

2017-05-15 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 15 May 2017 at 22:38:15 UTC, Jonathan M Davis wrote: Personally, I think that it would be very much worth making hello world larger, since hello world really doesn't matter, but because there are plenty of folks checking out D who write hello world and then look at the executable

Re: Jonathan Blow's presentation

2017-05-09 Thread Era Scarecrow via Digitalmars-d
On Tuesday, 9 May 2017 at 23:47:46 UTC, Era Scarecrow wrote: Seems some games they decided the small amount of time spent decompressing audio and textures was too high since the console hardware is seriously behind PC hardware. Found an appropriate articles Regarding Titanfall (a few years

Re: Jonathan Blow's presentation

2017-05-09 Thread Era Scarecrow via Digitalmars-d
On Tuesday, 9 May 2017 at 02:13:19 UTC, Nick Sabalausky (Abscissa) wrote: On 05/08/2017 03:28 PM, Jack Stouffer wrote: uncompressed audio. Uncompressed? Seriously? I assume that really means FLAC or something rather than truly uncompressed, but even still... Nope, uncompressed. Seems some

Re: Porting Java code to D that uses << and >>> operators

2017-05-01 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 1 May 2017 at 21:04:15 UTC, bachmeier wrote: On Monday, 1 May 2017 at 18:16:48 UTC, Era Scarecrow wrote: Reminds me... was the unsigned shift >>> ever fixed? What was wrong with it? Doing a broad test I'm seeing an issue with short & byte versions... Course that's probably due

Re: Porting Java code to D that uses << and >>> operators

2017-05-01 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 1 May 2017 at 15:53:41 UTC, Basile B. wrote: It's the same code in D. It extracts consecutive bits in x12 and x13 (and maskxx), put them at the beginning (right shift) and add them. Reminds me... was the unsigned shift >>> ever fixed?

Re: Garbage Collector?

2017-04-27 Thread Era Scarecrow via Digitalmars-d
On Thursday, 27 April 2017 at 19:36:44 UTC, Ben wrote: Frankly seeing in this example that the GC was in theory able to kick in 6 times in a simple 100 item loop, that is not efficient. I if did my own memory management, the variable cleanup will have been done in one go, right after the loop.

Re: Problems with Zlib - data error

2017-04-21 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 21 April 2017 at 17:40:03 UTC, Era Scarecrow wrote: I think I'll just go with full memory compression and make a quick simple filter to manage the large blocks of 0's to something more manageable. That will reduce the memory allocation issues. Done and I'm happy with the results.

Re: Problems with Zlib - data error

2017-04-21 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 21 April 2017 at 12:57:25 UTC, Adam D. Ruppe wrote: But I didn't realize your thing was a literal example from the docs. Ugh, can't even trust that. Which was a larger portion of why I was confused by it all than otherwise. Still, it's much easier to salvage if I knew how the

Re: Problems with Zlib - data error

2017-04-21 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 20 April 2017 at 20:24:15 UTC, Adam D. Ruppe wrote: In short, byChunk reuses its buffer, and std.zlib holds on to the pointer. That combination leads to corrupted data. Easiest fix is to .dup the chunk... So that's what's going on. But if I have to dup the blocks then I have

Problems with Zlib - data error

2017-04-20 Thread Era Scarecrow via Digitalmars-d-learn
I took the UnCompress example and tried to make use of it, however it breaks midway through my program with nothing more than 'Data Error'. [code] //shamelessly taken for experimenting with UnCompress decmp = new UnCompress; foreach (chunk; stdin.byChunk(4096).map!(x => decmp.uncompress(x)))

Re: Duplicated functions not reported?

2017-04-16 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 15 April 2017 at 11:10:01 UTC, Stefan Koch wrote: It would requires an O(n^2) check per declaration. Even it is never used. which would make imports that much more expensive. Seems wrong to me... If you made a list/array of all the functions (based purely on signatures) then

Re: Self-modifying code! The real kind!

2017-04-07 Thread Era Scarecrow via Digitalmars-d
On Friday, 7 April 2017 at 20:43:52 UTC, Stefan Koch wrote: On Thursday, 6 April 2017 at 05:36:52 UTC, Swoorup Joshi wrote: Self-modifying might be the answer to all sorts of performance problems due to branching. No it's not! You are throwing away your i-cache AND mess up the branch

Re: Error: out of memory

2017-03-19 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:39:20 UTC, StarGrazer wrote: I have some CTFE's and meta programming that cause dmd to run out of memory ;/ I am generating simple classes, but a lot of them. dmd uses about 2GB before it quits. It also only uses about 12% of cpu. I've noticed heavy use of

Re: Using chunks with Generator

2017-03-14 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 10:00:24 UTC, Tetiana wrote: Build fails with the following error: Just looking at the Documentation, Generator is an InputRange and chunks requires a ForwardRange (able to use save functionality). So the API doesn't match up more or less.

Re: Nested struct sauses error

2017-03-12 Thread Era Scarecrow via Digitalmars-d
On Sunday, 12 March 2017 at 18:59:43 UTC, Adam D. Ruppe wrote: The reason is that access to those local variables needs a hidden pointer that won't be initialized properly without the right construction. While it's the most likely reason for the error; Shouldn't it detect it never used

  1   2   3   4   >