Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread Cauterite via Digitalmars-d-learn
On Monday, 18 June 2018 at 09:28:00 UTC, rikki cattermole wrote: On 18/06/2018 9:24 PM, Mr.Bingo wrote: On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole wrote: This doesn't work with depreciation warnings. There won't be a way to check for those (I think). Easier to not worry about

Re: scope(success) lowered to try-catch ?

2018-06-18 Thread Cauterite via Digitalmars-d-learn
On Monday, 18 June 2018 at 03:58:47 UTC, Neia Neutuladh wrote: ... yeah, at an AST level it makes sense why it was implemented like this. it's unfortunate that there's no straightforward way to express 'finally(success) {'.

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Cauterite via Digitalmars-d-learn
On Sunday, 17 June 2018 at 12:10:33 UTC, Nicholas Wilson wrote: I suspect scope(success) is lowered because scope(exit) and scope(failure) are, and that would result in a simpler (compiler) implementation of it. does adding nothrow to main fix it? For dcompute I specifically allow

scope(success) lowered to try-catch ?

2018-06-17 Thread Cauterite via Digitalmars-d-learn
Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and scope(failure) to actually interact with exception handling, while scope(success) simply places code on

Re: Debugging on Windows

2018-02-11 Thread Cauterite via Digitalmars-d-learn
On Thursday, 8 February 2018 at 21:09:33 UTC, JN wrote: Hi, is there any way to debug binaries on Windows? I'd at least like to know which line of code made it crash. If it's D code, I get a call trace usually, but if it's a call to a C library, I get a crash and that's it. I am using VSCode

Re: Hash table element existence check

2016-09-03 Thread Cauterite via Digitalmars-d-learn
On Saturday, 3 September 2016 at 12:33:26 UTC, Illuminati wrote: On Saturday, 3 September 2016 at 07:44:28 UTC, Cauterite wrote: On Friday, 2 September 2016 at 19:38:34 UTC, Illuminati wrote: I am trying to create a hash table and would like an efficient way to be able to know if an element

Re: Hash table element existence check

2016-09-03 Thread Cauterite via Digitalmars-d-learn
On Friday, 2 September 2016 at 19:38:34 UTC, Illuminati wrote: I am trying to create a hash table and would like an efficient way to be able to know if an element exists to test for collisions. Just do a regular lookup on the hash? It's an O(1) operation, like 4 instructions.

Re: Equivalent of FirstOrDefault with ranges

2016-09-02 Thread Cauterite via Digitalmars-d-learn
On Friday, 2 September 2016 at 06:56:07 UTC, Lutger wrote: You could do: names.find("bob").chain(only(``)).front; It's not very expressive though.

testing for deprecation

2016-09-01 Thread Cauterite via Digitalmars-d-learn
How does one test whether a symbol is deprecated? I would have expected something like: __traits(isDeprecated, foo). In the compiler we have Dsymbol.isDeprecated, is that not accessible in any way from code? The only solution I can think of is compiling with -de and using __traits(compiles,

Re: Debug prints in @nogc

2016-08-31 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 16:17:51 UTC, Yuxuan Shui wrote: No. When you use assumeUnique, you know something the compiler does know, and have to use assumeUnique to tell the compiler that (at least when you use it correctly). But when you use assumeNogc, it's always because you want to

Re: Multi-threading how-to

2016-08-31 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 17:37:25 UTC, solidstate1991 wrote: I decided to add a functionality that if multiple programs use the same instance of the library on the same computer, the messages will be passed directly instead of via networking. What you're describing here is not actually

Re: Debug prints in @nogc

2016-08-31 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 15:10:11 UTC, Seb wrote: AssumeNogc is potentially dangerous, so I don't know whether it can make it directly, but only if you try you know ;-) So is assumeUnique

Re: D to C++

2016-08-31 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 11:43:12 UTC, Nick wrote: That's quite nice, but not what I'm looking for. What Calypso does, as far as I can see, is to make it possible to compile C++ and D together. I'm looking for a compiler that takes in D code and spits out either C or C++ code. Your

Re: Debug prints in @nogc

2016-08-30 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 14:38:47 UTC, Nordlöw wrote: Just being able to print a string is not good enough. I want the variadic part writeln so I can debug-print values in my buggy code. Do you have a similar solution? Take a look at the example here:

Re: Does D have anything like the generators of Python and some other languages?

2016-08-29 Thread Cauterite via Digitalmars-d-learn
On Monday, 29 August 2016 at 21:24:52 UTC, A D dev wrote: Hi group, Does D have anything like the generators of Python and some other languages? Thanks. Ranges serve some of the purposes that generators are often used for: http://dlang.org/phobos/std_range.html But you can of course

Re: Unicode function name? ∩

2016-08-29 Thread Cauterite via Digitalmars-d-learn
On Monday, 29 August 2016 at 12:53:26 UTC, Jesper Tholstrup wrote: Personally, I would prefer 'intersect' as a function name over '∩' anytime. Which benifits does the symbols add? Sounds like you'd love Java. x = new BigDecimal("0.1") x.negate().divide(y).compareTo(z) who needs symbols? >_>

Re: Unicode function name? ∩

2016-08-28 Thread Cauterite via Digitalmars-d-learn
On Sunday, 28 August 2016 at 05:21:03 UTC, Tofu Ninja wrote: Are unicode function names not supported in dmd? Here's a few ANSI characters you can use (and can type with alt-codes): ª º · Ø ø µ ƒ I use º pretty often, it makes a nice sigil.

Re: Proper concurrent nearly lock free efficient nogc storage structures?

2016-08-27 Thread Cauterite via Digitalmars-d-learn
On Saturday, 27 August 2016 at 01:06:53 UTC, Illuminati wrote: Surely one of the many intelligent people on this forum should be able to implement some of the basic structures fairly quickly? Most of these people are happy to use the GC, so @nogc structures are not a priority.

Re: Proper concurrent nearly lock free efficient nogc storage structures?

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 23:38:02 UTC, Illuminati wrote: Does D have any such thing? I'm having to recreate the wheel here and it isn't fun ;/ Getting in the way of real work ;/ @nogc is such a new language feature that you can't expect a lot of support yet from e.g. the standard

Re: Does D have any construct like Python's with keyword?

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 23:28:27 UTC, pineapple wrote: I've grown to very much appreciate how context initialization and teardown can be very conveniently handled using `with` in Python. Is there any clean way to imitate this syntax in D? Yep, scope guards. auto p = OpenProcess(...);

Re: using .init reliably

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 15:14:42 UTC, Steven Schveighoffer wrote: FYI, you cannot make this patch until we fully deprecate the use of TypeInfo.init: https://github.com/dlang/druntime/blob/master/src/object.d#L294 So at least until 2.075. -Steve Ah yes, good thinking. I'll keep that in

Re: using .init reliably

2016-08-26 Thread Cauterite via Digitalmars-d-learn
On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote: And I expect that it will become an error at some point in the future to define an init member for a user-defined type, at which point, there won't be any choice about fixing it. I might take a crack at this patch. Sounds

using .init reliably

2016-08-26 Thread Cauterite via Digitalmars-d-learn
How can I get the initial value of an arbitrary type? Since any struct can override it, .init is not reliable: struct Z { enum init = 6; string val = `asdf`; }; assert(Z.init == 6); assert(typeof(Z()).init == 6); I know I could use *(cast(Z*) typeid(Z).initializer.ptr) but that

Re: nested enum

2016-08-25 Thread Cauterite via Digitalmars-d-learn
On Thursday, 25 August 2016 at 10:36:21 UTC, Daniel Kozak wrote: Btw, tehre is no need for extra semicolon (`;`) after enum and struct definition Thanks. This forum insists on reminding me every time I write code here.

Re: nested enum

2016-08-25 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: Well those other answers aren't wrong, but I envisioned that you'd have multiple categories within your sub-enums and whatnot, so you'd need something more like this: struct A { enum X { one,

Re: Float values are wrong in union

2016-08-21 Thread Cauterite via Digitalmars-d-learn
On Monday, 22 August 2016 at 04:37:50 UTC, stunaep wrote: I made a union to convert between int bits and floats, but the values are coming out wrong sometimes. I can already tell what this is going to be... The problem is almost certainly nothing to do with your union, it's this line: float

Re: Mem Mgmt: With & Without the GC

2016-08-21 Thread Cauterite via Digitalmars-d-learn
On Sunday, 21 August 2016 at 18:31:26 UTC, Zane wrote: I see - That makes sense, but is there no way to "pause/stop" the GC, but still be able to use the 'new' syntax? Oh you can use `new` when the GC is disabled, no problem. All the GC's functionality is still available. But be careful

Re: Mem Mgmt: With & Without the GC

2016-08-21 Thread Cauterite via Digitalmars-d-learn
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote: 1) If using the GC, but for whatever reason, I need to free something _right now_, is core.GC.free() the proper way to do this? The main problem is that `new` does not necessarily give you a pointer to the start of an allocation, and

Re: Mem Mgmt: With & Without the GC

2016-08-21 Thread Cauterite via Digitalmars-d-learn
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote: 5) Is there a way to do simple heap allocation with 'new' while ensuring the GC doesn't deallocate until I want it to? While my earlier suggestion of using malloc/emplace is one option, another is to use `GC.addRoot(objPtr)`. It ensures

Re: Mem Mgmt: With & Without the GC

2016-08-21 Thread Cauterite via Digitalmars-d-learn
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote: 2) Does calling object.destroy() mean that the object is marked for future collection? If not, how can I ensure it is properly marked. Because the GC is not of the incremental type, it can't perform any marking outside of a

Re: Mem Mgmt: With & Without the GC

2016-08-21 Thread Cauterite via Digitalmars-d-learn
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote: 6) If the GC is off, how is allocation/deallocation handled? Can I still use new for example (and how do I dealloc)? All the allocation/deallocation functionality is the same as normal, except the GC won't start a collection cycle unless

Re: Mem Mgmt: With & Without the GC

2016-08-21 Thread Cauterite via Digitalmars-d-learn
On Sunday, 21 August 2016 at 16:14:53 UTC, Zane wrote: 5) Is there a way to do simple heap allocation with 'new' while ensuring the GC doesn't deallocate until I want it to? I can answer this at least, If you don't want the GC to ever collect the object itself, here's the best way: Allocate

Re: MurmurHash3 behaviour

2016-08-19 Thread Cauterite via Digitalmars-d-learn
On Friday, 19 August 2016 at 21:03:22 UTC, Seb wrote: http://dlang.org/phobos-prerelease/std_digest_murmurhash.html Ah great, I just finished writing my own murmurhash digest module ( https://github.com/Cauterite/phobos/blob/murmur/std/digest/murmur.d ), and now I discover someone's already

MurmurHash3 behaviour

2016-08-19 Thread Cauterite via Digitalmars-d-learn
Regarding the MurmurHash3 implementation in core.internal.hash, it is my understanding that: // assuming a and b are uints bytesHash([a, b], 0) == bytesHash([b], bytesHash([a], 0)) Is this correct? I'm just not quite certain of this property when I try to read the code myself, and I

Re: having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 13:33:26 UTC, Steven Schveighoffer wrote: I think the OP's case is a bug. Please file. Thanks, I've filed it. Just wanted to get a second opinion before concluding that it's a bug.

Re: having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 13:18:06 UTC, Adam D. Ruppe wrote: Best you can do is use them in an alias argument directly, but you cannot use them in an enum argument. I think you missed the point; it works perfectly fine without having this `({return 0;})()` in the template body (which,

having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Cauterite via Digitalmars-d-learn
// -- Example: -- template A(alias Arg) { enum A = Arg; enum Unrelated = ({return 0;})(); // this line prevent compilation }; void main() { enum FnPtr = enum _ = A!FnPtr; }; void asdf() {}; // ( https://dpaste.dzfl.pl/79301f12e5fc ) Just by having a

Re: When does take modify the underlying iterator?

2016-08-16 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 16 August 2016 at 21:01:14 UTC, cy wrote: This has also been annoying me lately, so I came up with this workaround: InputRange!T X = inputRangeObject(Src); X.take(6); // remove+return items 0 to 5 X.take(3); // remove+return items 6 to 8

Re: Passing Structs to function like in C

2016-08-14 Thread Cauterite via Digitalmars-d-learn
On Sunday, 14 August 2016 at 16:21:58 UTC, D.Rex wrote: so '();' works the same as 'foo.bar();'? with pointers, D automatically rewrites expressions like this: f.fooMethod() to this: (*f).fooMethod() which is why you're able to index an object-pointer-pointer (Foo*) the same

Re: if static member then call

2016-08-13 Thread Cauterite via Digitalmars-d-learn
On Saturday, 13 August 2016 at 18:34:43 UTC, Engine Machine wrote: static if (hasStaticMember!(T, "foo")) Here I suspect you're looking for this: __traits(isStaticFunction, __traits(getMember, T, "foo"))

Re: if static member then call

2016-08-13 Thread Cauterite via Digitalmars-d-learn
On Saturday, 13 August 2016 at 18:34:43 UTC, Engine Machine wrote: auto ref foo(T, Args...)(args) { static if (hasStaticMember!(T, "foo")) return T.foo!(T)(args); } Basically I want to forward the *static* call to T if possible(if foo exists in T). The main problem is actually

Re: Passing Structs to function like in C

2016-08-13 Thread Cauterite via Digitalmars-d-learn
On Saturday, 13 August 2016 at 15:47:51 UTC, D.Rex wrote: /* memory.d file */ module memory; import include.linux.sched;/* contains task_struct definition */ void free_page_tables(task_struct* tsk) { /* do something with */ } And to use the method from somewhere else /* use

Re: 'importing' threads — i.e. thread_attachThis()

2016-08-12 Thread Cauterite via Digitalmars-d-learn
On Friday, 12 August 2016 at 18:59:35 UTC, Guillaume Piolat wrote: On Friday, 12 August 2016 at 10:45:22 UTC, Cauterite wrote: Thanks, this is very helpful. I already feel much more confident about the idea. My use is definitely the 'whole-lifetime' case, so I might be able to get away

Re: Passing Structs to function like in C

2016-08-12 Thread Cauterite via Digitalmars-d-learn
Thanks colon-nazis, I'll take that into consideration ¬_¬

Re: Passing Structs to function like in C

2016-08-12 Thread Cauterite via Digitalmars-d-learn
On Friday, 12 August 2016 at 16:50:43 UTC, ag0aep6g wrote: On 08/12/2016 05:23 PM, Cauterite wrote: No semicolon there, please. Why would I not terminate a declaration with a semi-colon? Why should a declaration not end in a semi-colon just because the last token is a brace? Why should I not

Re: Passing Structs to function like in C

2016-08-12 Thread Cauterite via Digitalmars-d-learn
On Friday, 12 August 2016 at 15:21:22 UTC, D.Rex wrote: extern unsigned long free_page_tables(struct task_struct * tsk); extern(C) ulong free_page_tables(task_struct* tsk); void main() { task_struct tsk = …… ; free_page_tables(); }; That should be what you're after?

'importing' threads — i.e. thread_attachThis()

2016-08-12 Thread Cauterite via Digitalmars-d-learn
I'm planning on 'importing' a thread into the D runtime using thread_attachThis(), and was just wondering about the potential pitfalls of this process. For example: - Would having an entry function other than core.thread.thread_entryPoint() pose problems? What about during stack unwinding?

Re: method static-ness has no effect on the type?

2016-08-08 Thread Cauterite via Digitalmars-d-learn
On Monday, 8 August 2016 at 10:21:47 UTC, ag0aep6g wrote: Also thanks for submitting the bug for me.

Re: method static-ness has no effect on the type?

2016-08-08 Thread Cauterite via Digitalmars-d-learn
On Monday, 8 August 2016 at 10:05:58 UTC, ag0aep6g wrote: The first assert compares the return types of f1 and f2. They both return `void`, so everything's fine there. I think you're mistaken about this. typeof(S.f1) definitely gives the type of the function, not of the return. Try it out:

Re: Tracking memory usage

2016-08-08 Thread Cauterite via Digitalmars-d-learn
On Sunday, 7 August 2016 at 00:28:40 UTC, Alfred Pincher wrote: this is a very nice feature. I hope D has something similar? If you want to implement that kind of allocation tracking you'll probably want to use gc_getProxy()+gc_setProxy(). They're global C functions you can access by

method static-ness has no effect on the type?

2016-08-08 Thread Cauterite via Digitalmars-d-learn
See: https://dpaste.dzfl.pl/2ec6780d4b25 We have two methods defined, f1 and f2, where f2 is static but they have otherwise identical signatures. We can see from the disassembly that f1 receives a `this` pointer while f2 does not. Yet, typeof() == typeof(). This makes no sense, how can the

Re: Cannot distinguish between template function wtih 0 args and 1 arg

2016-08-08 Thread Cauterite via Digitalmars-d-learn
On Monday, 8 August 2016 at 02:36:24 UTC, Engine Machine wrote: Error: template Mem cannot deduce function from argument types !(cast(eException)1280L, "main.d", 38u, "main.WinMain")(int), candidates are: Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func =

Re: assert or throw in range members?

2016-08-05 Thread Cauterite via Digitalmars-d-learn
On Friday, 5 August 2016 at 10:25:42 UTC, Nordlöw wrote: Should range members front() and back() assert() or throw() on emptyness? I'm pretty sure it's assert() here. The contract is that the caller is responsible for checking emptiness beforehand, and the whole of Phobos is coded around

Re: Does D have object wrappers for primitives?

2016-07-30 Thread Cauterite via Digitalmars-d-learn
On Saturday, 30 July 2016 at 04:12:45 UTC, stunaep wrote: Thank you. This is just what I needed. I am curious though as to why this doesn't work with strings. It would work if I removed immutable from the Boxed constructor but I thought strings were immutable. I get a compiler error 'not

Re: Does D have object wrappers for primitives?

2016-07-29 Thread Cauterite via Digitalmars-d-learn
On Friday, 29 July 2016 at 20:26:47 UTC, Ali Çehreli wrote: I was going to suggest Algebraic because it allows arrays of mixed primitive types (wrapped in Algebraic): https://dlang.org/phobos/std_variant.html#.Algebraic Ali It could work, but keep in mind Algebraic is a structure, not

Re: Does D have object wrappers for primitives?

2016-07-29 Thread Cauterite via Digitalmars-d-learn
On Friday, 29 July 2016 at 20:13:34 UTC, stunaep wrote: I have some java code I need to convert and at one point it uses an Object[] array to store various ints, longs, and strings. Java has built in Integer and Long classes that wrap the primitives in an object and strings are already

Re: When I should to call destroy?

2016-07-29 Thread Cauterite via Digitalmars-d-learn
On Friday, 29 July 2016 at 13:18:00 UTC, Suliman wrote: But I can't understand if D have GC it should remove objects when their life is finished. When I should to call `destroy`? What would be if I will not call it? `destroy` is mainly about running destructors deterministically. From the

Re: question about conditional operator (?:)

2016-07-26 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 13:09:28 UTC, Richard wrote: Hello all, try using some parentheses: (n%p==0) ? (n/=p) : (p+=1) ;

Re: Static ternary if

2016-07-26 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 00:54:59 UTC, Michael Coulombe wrote: If that's ok, then try out std.traits.Select or std.traits.select: https://dlang.org/phobos/std_traits.html#Select Damn, I looked real hard for that template, I knew it existed. I expected it to be in std.meta though.

Re: Static ternary if

2016-07-25 Thread Cauterite via Digitalmars-d-learn
On Monday, 25 July 2016 at 02:15:12 UTC, Gorge Jingale wrote: Is there a static ternary if? (A == B) ? C : D; for compile type that works like static if. You can pretty easily make your own; template staticIf(bool cond, alias a, alias b) { static if (cond) { alias staticIf = a;

Re: Trouble checking for null-ness

2016-07-25 Thread Cauterite via Digitalmars-d-learn
On Monday, 25 July 2016 at 12:47:25 UTC, Cauterite wrote: (!__traits(compiles, r is null) || r !is null) && !r.empty Ah, whoops that's wrong, looks like ketmar had the right idea.

Re: Trouble checking for null-ness

2016-07-25 Thread Cauterite via Digitalmars-d-learn
On Monday, 25 July 2016 at 12:37:18 UTC, Bahman Movaqar wrote: But I'm curious; how can I check for a `null` in this case? Well, if you're happy with assertion failure by access violation, you may not even need to check for null, because generally if you try to call .empty on a null pointer

Re: debug public release private

2016-07-24 Thread Cauterite via Digitalmars-d-learn
On Monday, 25 July 2016 at 04:58:55 UTC, Gorge Jingale wrote: debug mixin("public"); else mixin("private"); Perhaps you could build a patched DMD which ignores 'private'. Then when you want to compile with -debug, use this custom DMD, and use the standard DMD the rest of the time. I

Re: why does this error out?

2015-11-09 Thread Cauterite via Digitalmars-d-learn
Here's the output I get (DMD v2.068.2): [1, 3, 10, 12, 21, 30, 100, 102, 111, 120, 201, 210] core.exception.AssertError@std\range\package.d(4603): Assertion failure

Re: dpaste.dzfl.pl is blocked

2015-11-07 Thread Cauterite via Digitalmars-d-learn
On Saturday, 7 November 2015 at 11:25:39 UTC, drug wrote: What are alternatives for it? Thanks. Right here: http://wiki.dlang.org/Online_compilers dpaste.dzfl.pl is the best one though :/

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread Cauterite via Digitalmars-d-learn
On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote: On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll D doesn't make particularly heavy use of the C runtime, so there's a good chance you can link against a different C runtime DLL —

Re: D bindings for Bonjour

2015-10-28 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote: Hi, I am starting my first project in D and I would like to do a Bonjour(Zeroconf) browser app. My first task is to write a binding to the dns_sd library but I have an issue with the following macro: #define

Re: How to get DMD to stop littering my source dir with .o files?

2015-10-26 Thread Cauterite via Digitalmars-d-learn
The problem is that the compiler and linker are separate programs; the compiler has to generate input for the linker in the form of a file. RDMD automatically cleans up all the .obj garbage, so one solution is to run rdmd --build-only asdf.d Also, the -of flag is a little more

Re: Does D's GC release memory back to the OS?

2015-10-26 Thread Cauterite via Digitalmars-d-learn
On Sunday, 25 October 2015 at 08:56:52 UTC, Jonathan M Davis wrote: It is my understanding that the GC does not normally ever return memory to the OS It seems that it does now. In smallAlloc() and bigAlloc(), if allocation fails it collects garbage and then: if (lowMem) minimize(); On

Re: Does D's GC release memory back to the OS?

2015-10-26 Thread Cauterite via Digitalmars-d-learn
Correction: you said "the GC does not normally ever return memory" and you're right, because applications do not "normally" consume >95% of their address space.

Re: `clear`ing a dynamic array

2015-10-24 Thread Cauterite via Digitalmars-d-learn
I'm afraid what you're asking for is impossible. Because 'a' and 'b' are both slices, they each have their own 'length' field. When you do 'a = []', you're effectively doing 'a.length = 0'. There's no way to change 'b.length' through 'a'. To get that effect, you'd have to do something like

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread Cauterite via Digitalmars-d-learn
On Thursday, 22 October 2015 at 04:25:01 UTC, MobPassenger wrote: On Thursday, 22 October 2015 at 04:01:16 UTC, Mike Parker wrote: On Thursday, 22 October 2015 at 03:19:49 UTC, MobPassenger wrote: code: --- struct Foo { bool opIn_r(T)(T t){return false;} } This needs to be marked with

Re: enum to flags

2015-09-29 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? You could cheat with operator overloading: enum blah {