Re: chain of exceptions, next method
On Sunday, 14 August 2022 at 02:30:43 UTC, Paul Backus wrote: On Sunday, 14 August 2022 at 02:07:05 UTC, Ali Çehreli wrote: This automatic "combining" of exceptions happens for cleanup code like scope(exit). (I remember bug(s) for scope(failure).): To be precise, an exception thrown inside a 'finally' block gets chained onto the previous exception, but an exception thrown inside a 'catch' block does not. scope(exit) and scope(failure) are just syntax sugar for 'finally' and 'catch', respectively. I wish the compiler would rewrite scope(failure) to use chained exceptions. Otherwise any exceptions thrown within scope(failure) can end up losing information about what was the original exception that was thrown.
Re: A function to split a range into several ranges of different chunks
On Monday, 14 September 2020 at 09:08:01 UTC, Seb wrote: You likely want to get involved / raise your support here: https://github.com/dlang/phobos/pull/7600 Oh this is great, thank you!
A function to split a range into several ranges of different chunks
- import std.range; import std.stdio; void main () { auto range = sequence!((a, n) => n); // works, but the chunks are all the same length auto rngs = range.chunks(4); writeln(rngs[0]); writeln(rngs[1]); writeln(rngs[2]); // want this auto ranges = range.???(3, 4, 5); writeln(ranges[0] == [1, 2, 3]); writeln(ranges[1] == [4, 5, 6, 7]); writeln(ranges[2] == [8, 9, 10, 11, 12]); } - Do you know of a simple way to do this? It's essentially similar to chunks, except the chunks themselves would not be of the same length. You can think of a good name for '???' here. Maybe this is already possible by combining functionality in std.range - but I came up short.
Re: How do I convert an ISO 8601 datetime into a unix timestamp - at compile-time?
On Friday, 28 August 2020 at 12:35:26 UTC, Steven Schveighoffer wrote: It's trying to look up the local timezone at compile time. You need to specify a time zone: static time = SysTime(DateTime.fromISOString("20220101T00"), UTC()).toUnixTime; -Steve Aw, thanks Steve!
Re: How do I convert an ISO 8601 datetime into a unix timestamp - at compile-time?
On Friday, 28 August 2020 at 01:54:02 UTC, Andrej Mitrovic wrote: - import std.datetime; void main () { static time = SysTime(DateTime.fromISOString("20220101T00")).toUnixTime; } - I think I'm supposed to use MonoTime here, right?
How do I convert an ISO 8601 datetime into a unix timestamp - at compile-time?
- import std.datetime; void main () { static time = SysTime(DateTime.fromISOString("20220101T00")).toUnixTime; } - - /Library/D/dmd/src/phobos/std/concurrency.d(2574): Error: static variable lock cannot be read at compile time /Library/D/dmd/src/phobos/std/concurrency.d(2574):called from here: atomicLoad(lock) /Library/D/dmd/src/phobos/std/concurrency.d(2600):called from here: initOnceLock() /Library/D/dmd/src/phobos/std/concurrency.d(2600):called from here: initOnce(delegate shared(bool)() pure @nogc @safe => init(), initOnceLock()) /Library/D/dmd/src/phobos/std/datetime/timezone.d(1106): called from here: initOnce(delegate shared(bool)() pure nothrow @nogc @safe => (*function () nothrow @nogc @safe => true)()) /Library/D/dmd/src/phobos/std/datetime/timezone.d(546): called from here: (*& singleton)() /Library/D/dmd/src/phobos/std/datetime/systime.d(524): called from here: opCall() /Library/D/dmd/src/phobos/std/datetime/systime.d(472): called from here: this.this(dateTime, zero(), tz) test.d(6):called from here: SysTime(0L, Rebindable(null, )).this(fromISOString("20220101T00"), null) - I'm sure there must be a better way to do this. But I couldn't find it in the documentation.
Re: Why is time_t defined as a 32-bit type on Windows?
On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic wrote: ``` C:\dev> rdmd -m64 --eval="import core.stdc.time; writeln(time_t.sizeof);" 4 ``` According to MSDN this should not be the case: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019 time is a wrapper for _time64 and **time_t is, by default, equivalent to __time64_t**. But in Druntime it's defined as a 32-bit type: https://github.com/dlang/druntime/blob/349d63750d55d078426d4f433cba512625f8a3a3/src/core/sys/windows/stdc/time.d#L42 I filed it as an issue to get more eyes / feedback: https://issues.dlang.org/show_bug.cgi?id=21134
Re: Why is time_t defined as a 32-bit type on Windows?
On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic wrote: ``` C:\dev> rdmd -m64 --eval="import core.stdc.time; writeln(time_t.sizeof);" 4 ``` According to MSDN this should not be the case: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019 time is a wrapper for _time64 and **time_t is, by default, equivalent to __time64_t**. But in Druntime it's defined as a 32-bit type: https://github.com/dlang/druntime/blob/349d63750d55d078426d4f433cba512625f8a3a3/src/core/sys/windows/stdc/time.d#L42 It looks like this definition was there from at least 2008 (!!), and probably earlier than that but I don't have the SVN sources: https://github.com/dlang/druntime/blob/6837c0cd426f7e828aec1a2bdc941ac9b722dd14/import/stdc/time.d#L49 So basically, just around the time the first 64-bit version of Windows was released. I'm guessing it was just neglected..
Why is time_t defined as a 32-bit type on Windows?
``` C:\dev> rdmd -m64 --eval="import core.stdc.time; writeln(time_t.sizeof);" 4 ``` According to MSDN this should not be the case: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019 time is a wrapper for _time64 and **time_t is, by default, equivalent to __time64_t**. But in Druntime it's defined as a 32-bit type: https://github.com/dlang/druntime/blob/349d63750d55d078426d4f433cba512625f8a3a3/src/core/sys/windows/stdc/time.d#L42
What is the point of a synchronized lock on a single return statement?
From: https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8c03/std/concurrency.d#L1913-L1916: - /// final @property bool isClosed() @safe @nogc pure { synchronized (m_lock) { return m_closed; } } - I don't understand the purpose of this lock. The lock will be released as soon as the function returns, and it returns a copy of a boolean anyway. Am I missing something here?
Re: Anyone have a Vibe.d Diet Template syntax definition for Sublime?
On Monday, 22 April 2019 at 04:12:11 UTC, Andrej Mitrovic wrote: Or perhaps for any other editor so I could adapt it and have syntax highlighting in Sublime when viewing .dt files. In the meantime I found this: https://packagecontrol.io/packages/Pug It seems to work fairly well.
Anyone have a Vibe.d Diet Template syntax definition for Sublime?
Or perhaps for any other editor so I could adapt it and have syntax highlighting in Sublime when viewing .dt files.
Re: Asio Bindings?
On 6/9/16, Joerg Joergonson via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > Why would bindings have any issues with licensing? Just to show that I'm not full of shit, here's the e-mail chain: On 6/3/11, Andrej Mitrovic <andrej.mitrov...@gmail.com> wrote: > Hello, > > I'm currently porting the Steinberg VST and ASIO SDKs for use with the > D programming language. I would like to know if there are any special > licensing requirements before I can publish the source code to a > public repository. > > Specifically, do I need to print out the licensing agreement PDF > document, sign it, and send it via snail-mail to Steinberg? I'm > currently unemployed, so there shouldn't be any issues from my part > with regards to signing any licensing agreements, if that's required. > > The bindings themselves won't distribute any C/C++ header or > implementation files from the SDK, as the D language can't use C > header files directly. > > > Kind regards, > Andrej Mitrovic > On 6/7/11, Yvan Grabit <y.gra...@steinberg.de> wrote: > Hi Andrej > > i will speak with our internal Product planning people about your > concern... > I will keep you inform about our decision as soon as we have a decision... > > Cheers > > Yvan > > Yvan Grabit mailto:y.gra...@steinberg.de > Technical Manager - Technology Group Phone: +49-40-21035125 > Steinberg Media Technologies GmbHFax : +49-40-21035300 > Neuer Hoeltigbaum 22-32, D-22143 Hamburg/Germany > http://www.steinberg.net > On 6/23/11, Andrej Mitrovic <andrej.mitrov...@gmail.com> wrote: > Hello Yvan, > > I apologize if this e-mail is unnecessary and a decision is yet to be > made. If you are too busy should I try to contact one of Steinberg's > official representatives? > > I am willing to provide the source code for examination to Steinberg > if this could help verify that I'm not breaking any licensing > requirements. > > Have a nice day, > Andrej Mitrovic > On 6/23/11, Yvan Grabit <y.gra...@steinberg.de> wrote: > Hi > > we have examine your request, and decide due to our current VST/ASIO > license that you are not allowed to deploy/distribute a copy of the > VST/ASIO SDK (partially or full). > We will investigate a way to change our licensing for research or > educational use. > > In your concrete case, could it be not possible to ask the people you give > your source using the VST SDK (or ASIO) to download the VST-SDK (or ASIO) > (and agree the agreement) and provide a compiler macro (or something > different) which will convert the VST /ASIO interface to something D > compatible ? > > By the way how can we guaranty that the VST plugin or ASIO component > developed in D could be load by a host developed in C ? > > Cheers > > Yvan > > > Yvan Grabit mailto:y.gra...@steinberg.de > Technical Manager - Technology Group Phone: +49-40-21035125 > Steinberg Media Technologies GmbHFax : +49-40-21035300 > Neuer Hoeltigbaum 22-32, D-22143 Hamburg/Germany > http://www.steinberg.net > On 6/23/11, Andrej Mitrovic <andrej.mitrov...@gmail.com> wrote: > On 6/23/11, Yvan Grabit <y.gra...@steinberg.de> wrote: >> In your concrete case, could it be not possible to ask the people you >> give >> your source using the VST SDK (or ASIO) to download the VST-SDK (or >> ASIO) >> (and agree the agreement) and provide a compiler macro (or something >> different) which will convert the VST /ASIO interface to something D >> compatible ? > > Yes, I believe I can do that. For ASIO, I have the following: > > - A "Loader", which is a source file made from scratch which searches > for ASIO entries in the Windows Registry and provides a class which > can load and initialize any found ASIO drivers. Through this class > user code calls functions like "canSampleRate", "outputReady", etc. > > The Loader only requires the type definitions found in the > asiosdk\common\asio.h header file. This header file can be > automatically converted to D via an existing tool, and the Loader > would then import the newly converted header file and use the type > definitions. > > The Loader requires the OpenAsio DLL that can be found here: > http://www.martinfay.com/openasio.htm > > The
Re: Asio Bindings?
I do have (Steinberg) ASIO binding in D. The problem is I couldn't release the bindings. I've asked Steinberg if it was OK to release D bindings and they were strongly against it unfortunately (and this was over 3 years ago..). Any kind of direct use of ASIO requires their approval first.. meaning you had to register on their website. I would recommend using third party libs that abstract the underlying engine, like PortAudio or RtAudio (the later of which I'm going to release a port of soon!). I had a binding to PortAudio but the devs of that library insisted on only supporting interleaved audio, RtAudio supports both interleaved and non-interleaved audio, and the library is easy to port. On 6/2/16, Pie? via Digitalmars-d-learnwrote: > On Thursday, 2 June 2016 at 11:15:59 UTC, Guillaume Piolat wrote: >> On Thursday, 2 June 2016 at 06:28:51 UTC, Pie? wrote: >>> On Thursday, 2 June 2016 at 04:52:50 UTC, Mithun Hunsur wrote: On Thursday, 2 June 2016 at 04:02:36 UTC, Pie? wrote: > Does anyone know if there is any Asio bindings or direct D > available that allows for IO? Check out vibe.d: https://vibed.org/ - it includes a fairly complete implementation of asynchronous I/O, among other things. >>> >>> Oh, lol, I should have mentioned I meant for audio! ;) >> >> It doesn't seem to exist but using bindings for FMOD you should >> be able to access ASIO as an audio driver. > > If FMOD is that commercial sound lib then I'm not interested. I > guess I'll have to try and write some type of asio lib when I get > around to it. Hopefully it is not too difficult. >
Re: Speed up `dub`.
On Thursday, 2 June 2016 at 13:04:00 UTC, ciechowoj wrote: and found that an assert from `std/path.d:3168` (`globMatch`) contributes a major amount to the running time of dub. ``` assert(balancedParens(pattern, '[', ']', 0)); assert(balancedParens(pattern, '{', '}', 0)); ``` Hmm.. that sounds like the dub binary that's distributed is running its unittests at start. If that's true I don't think they should be part of the released binary..
Re: Linker error
On 6/5/16, Anonymous via Digitalmars-d-learnwrote: > Should I report this as a dmd bug then? Not sure where / how to > do that. You can report it here: https://issues.dlang.org > I think I'll just let it go; I was able to work passed it anyway > using "static Note[] empty;", and `null` works too. Is either one > better? null is simpler from a reader's perspective. :) > By the way, this is from an example I found in "D Web > Development" by Kai Nacke. Interesting that they would use such code in the book. Which chapter is it?
Re: Linker error
On 6/5/16, Anonymous via Digitalmars-d-learnwrote: > static Note[0] empty; > > Note[] getNotes(string id) > { > return (id in store) ? store[id] : empty; > } It's likely an accepts-invalid bug, meaning it should be a compiler error instead. I don't think it makes sense that the compiler tries to slice a fixed-length array of length zero.. tho perhaps it should just equate that to returning null. In any case you can return `null` instead of "empty". Fixed-length arrays of length zero aren't really all that well-defined. Some would say they make no sense, but there is a weird benefit to them when used with the built-in hashmaps (a void[0] value type wouldn't allocate memory, AFAIR and if that is still true).
Re: Array start index
On 8/1/15, DLearner via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D is a C derivative, so it seems a shame not to identify causes of bugs in C, and design them out in D. This has already been done! D defines an array to be a struct with a pointer and a length. See this article: http://www.drdobbs.com/architecture-and-design/cs-biggest-mistake/228701625 I would argue it's not off-by-one that's causing most issues when dealing with C arrays, but instead it's in general out-of-bounds issues (whether it's off bye one or off by 50..) since you often don't have the length or could easily use the wrong variable as the length. Think about how much D code would actually have subtle off-by-one errors if D didn't use 0-based indexing like the majority of popular languages use. Any time you would interface with other languages you would have to double, triple-check all your uses of arrays. FWIW at the very beginning I also found it odd that languages use 0-based indexing, but that was before I had any significant programming experience under my belt. By now it's second nature to me to use 0-based indexing.
Re: Static if to compare two types are the exact same
On 4/6/15, Jonathan via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: What's the best way to do this? I'm assuming this should be best practice: http://dlang.org/traits.html#isSame struct S { } writeln(__traits(isSame, S, S)); I'm not even sure when or why this trait was introduced, but you could use a simple is() expression for this, e.g.: static if (is(T == S)) { ... }
Re: Can the order in associative array change when keys are not midified?
On 1/1/15, Peter Alexander via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The order is unspecified, but an iteration must iterate in *some* order. The question (if I've understood it correctly), is whether that order of iteration changes when the keys aren't changed. Hmm yeah, that definitely wasn't ever specified. But remember that there is also a .rehash() method. It's a bit tricky to work with AAs for sure.. The spec doesn't say anything about this, although I would expect in practice that the order will not change. I've added a bug to track this omission from the spec: https://issues.dlang.org/show_bug.cgi?id=13923 Thanks.
Re: Can the order in associative array change when keys are not midified?
On 1/1/15, Idan Arye via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change? Associative arrays are not ordered at all. See the first note here: http://dlang.org/hash-map.html
Re: Can the order in associative array change when keys are not midified?
On 1/1/15, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If you need consistent ordering of values, you probably want a different data structure, like an ordered map This one works nicely on D1, I'd imagine the D2 port works just the same: https://github.com/SiegeLord/Tango-D2/blob/d2port/tango/util/container/SortedMap.d
Re: Can the order in associative array change when keys are not midified?
On 1/1/15, Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You could implement an OrderedMap!(Key, Value) via RedBlackTree!(Tuple!(Key, Value), (a,b) = a[0] b[0]). We could add this as an alias into Phobos or perhaps as just a documentation line on the website.
Re: Access Violation Tracking
On Nov 5, 2014 12:10 PM, Bauss via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is there any way to track down access violations, instead of me having to look through my source code manually. Whenever you don't get a stack trace on Windows, it's 99% guaranteed you're calling a null function pointer. I have a pretty big source code and an access violation happens at runtime, but it's going to be a nightmare looking through it all to find the access violation. Not to mention all the tests I have to run. So if there is a way to catch an access violation and find out where it occured it would be appreciated!
Re: Strange segfault (Derelict/OpenGL)
On 8/29/14, Robin Schroer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I definitely reload after setting the context and before trying to render. Typically these kinds of errors happen when a null function pointer is called. I'd add a few checks in some places to see what might have been left uninitialized.
Re: __VERSION__ and the different compilers
On 7/9/14, Mike Parker via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is it safe to assume that __VERSION__ is the same among DMD, LDC and GDC when using the equivalent front-end? Yes, but not all future compilers might implement this (although I hope they will). I think there's also __VENDOR__ IIRC.
Re: assocArray.get(key, default) exists?
On Saturday, June 21, 2014, Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: IS there such method get(key, default) for associative arrays, like in Python? I think it's named getDefault, try that.
Re: enum functions
On Saturday, June 21, 2014, Paul D Anderson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Does enum have any effect on functions? I think that's just a parser bug.
Re: enums
This has been asked so many times, is this info not on the website? We should have an article on the site explaining this in depth. OT: Sorry for top-quoting and over-quoting. On Friday, May 30, 2014, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 30 May 2014 at 15:30:15 UTC, Russel Winder via Digitalmars-d-learn wrote: I think I have no idea what D enums are about. Bearophile's example of some code in an email on another thread uses: enum double p0 = 0.0045; Now I would have written: immutable double p0 = 0.0045; or at the very worst: const double p0 = 0.0045; For me, enum means create an enumerated type. Thus enum double to define a single value is just a contradiction. Enlightenment required… The keyword enum stems from the enum hack in C++, where you use: enum {foo = 100}; //Or similar As a way to declare a manifest constant known at compile time. D simply hijacked the enum keyword to mean manifest constant that is known at compile time. Compared to an immutable instance: * The immutable instance creates an actual reference-able object in your binary. The enum will not exist outside of the compilation (think of it as a higher order macro) * immutable represents a value, which *may* be initialized at runtime. In any case, more often than not (I have observed), the compiler will refuse to use the immutable's value as compile-time known, and it won't be useable as a template parameter, or static if constraint.
Re: derelict glfw won't set callbacks
On 5/24/14, Vlad Levenfeld via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Any attempt to set callbacks in GLFW returns a null and the callback doesn't work. The first enforcement fails in this example: DerelictGLFW3.load (); enforce (glfwSetErrorCallback (error_callback)); It's ok if this fails because this is how it's documented: * @return The previously set callback, or `NULL` if no callback was set or an * error occurred. Below is a full snippet of using DerelictGLFW and a simple escape key binding: - import derelict.glfw3.glfw3; import std.conv; import std.exception; import std.stdio; shared static this() { DerelictGLFW3.load(); } extern(C) void error_callback(int error, const(char)* description) nothrow { printf(%s %s, error, description); } int main() { /* Initialize the library */ enforce(glfwInit()); glfwSetErrorCallback(error_callback); GLFWwindow* window; /* Create a windowed mode window and its OpenGL context */ window = glfwCreateWindow(640, 480, Hello World, null, null); scope(exit) glfwTerminate(); enforce(window !is null); /* Make the window's context current */ glfwMakeContextCurrent(window); extern(C) void onKeyEvent(GLFWwindow* window, int key, int scancode, int state, int modifier) nothrow { if (key == GLFW_KEY_ESCAPE state == GLFW_PRESS) glfwSetWindowShouldClose(window, true); } glfwSetKeyCallback(window, onKeyEvent); /* Loop until the user closes the window */ while (!glfwWindowShouldClose(window)) { /* Render here */ /* Swap front and back buffers */ glfwSwapBuffers(window); /* Poll for and process events */ glfwPollEvents(); } return 0; } -
Re: Is it possible to check if a type is an instance of a template?
On 5/6/14, bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: There is now std.traits.isInstanceOf that could do what you need. Someone resurrected a thread from 2011. Of course there's isInstanceOf when I added it myself at the end of 2012.
Re: formattedWrite writes nothing
On 5/2/14, ref2401 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: class MyClass { Appender!string _stringBuilder; this() { _stringBuilder = Appender!string(null); _stringBuilder.clear(); Ouch, ouch, ouch! What's happening is that the 'clear' Appender method is only compiled-in if the data is mutable, otherwise you end up calling the object.clear UFCS function. So don't use clear here. I don't know if this is a case of poor method naming or another downside of UFCS. Luckily 'clear' is being renamed to 'destroy' in the object module, so this specific case will not become a problem in the future.
Re: private constructors and inheritance
On 4/29/14, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The fact that call to base constructor is not inserted into templated this()() looks like a bug to me. Just found this, and it might be related: https://issues.dlang.org/show_bug.cgi?id=5770
Re: How to use the result of __traits( allMembers , T ) with string mixins ?
On Monday, 28 April 2014 at 13:52:52 UTC, ParticlePeter wrote: DMD tells me Error: variable m cannot be read at compile time, but why ? Because 'static foreach' is not an explicit feature yet, so it depends on the context. When you wrap the trait via: [__traits(allMembers, MyStruct)] You're creating an array, and foreach will *not* by default attempt to become a static foreach, even if the array is known at compile-time. If you remove the parentheses it will work. You've had a few bugs in the mixin code though, anyway here's the working sample: - import std.stdio; struct MyStruct { float float_value = 0.0f; ubyte ubyte_value = 2; } enum members = __traits(allMembers, MyStruct); void main() { foreach (m; members) { mixin(writeln( ` ~ m ~ ` , \ : \ , ( MyStruct. ~ m ~ .offsetof ) );); } } -
Re: How to use the result of __traits( allMembers , T ) with string mixins ?
On 4/28/14, ParticlePeter via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I found the code with parenthesis in the dlang __traits docs and also Philippe Sigauds D Templates, and I haven't seen any other example which works without them. So, when to use which syntax ( for which purpose ) ? If you need to store the tuple as an array to some variable, then you would use that syntax. It all depends on what you're trying to do from the call site. Ultimately it won't matter much once we finally get a proper 'static foreach' feature in D.
Re: Can I circumvent nothrow?
On 4/27/14, Damian Day via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: So I have this procedure. Have a look at std.exception.assumeWontThrow: http://dlang.org/phobos/std_exception.html#.assumeWontThrow
Re: Another bug in function overloading?
On 4/26/14, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: No. That's expected. I wonder whether a better diagnostic could help. But then again, maybe the hiding would be intentional and the diagnostic would be spurious/invalid. Not sure..
Re: Partial ordering of constructors with type parameters
On 4/24/14, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: *That* creates a conflict though :/ Are you sure? I can't reproduce.
Re: Named template constraints
On 4/22/14, Tim Holzschuh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: What does (inout int = 0) mean/affect here? This was asked recently, see my reponse here: http://forum.dlang.org/post/mailman.102.1396007039.25518.digitalmars-d-le...@puremagic.com
Re: Array of interface only with cast()?
On Tuesday, 22 April 2014 at 15:19:55 UTC, Andre wrote: Is the cast really needed? It's a known issue and a filed bug report. I don't have the Issue number at hand though, someone else will likely provide it.
Re: Named template constraints
On 4/22/14, Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com I think this can be fixed a different way. Feel free to file a bug / make a pull. :
Re: std.file.read returns void[] why?
On 4/18/14, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Yeah... static assert(void.sizeof == 1); passes :/ Note that you can even have static void arrays. E.g.: https://issues.dlang.org/show_bug.cgi?id=9691 I'm not sure whether this is an oversight (accepts-invalid) or something else. But it needs to be properly documented.
Re: Struct size
On 4/19/14, Lars T. Kyllingstad via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Say I have two structs, defined like this: struct A { /* could contain whatever */ } struct B { A a; } My question is, is it now guaranteed that A.sizeof==B.sizeof? The best thing to do is add a static assert and then you can relax: - struct A { } struct B { A a; } static assert(A.sizeof == B.sizeof); - As for the ABI, I don't think I've ever seen it mentioned anywhere.
Re: Template method and type resolution of return type
On 4/19/14, matovitch via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: This won't compile : import std.stdio; void main() { Test t; t.data = [152, 32, 64, 28, 95]; float b = t.get; writefln(%s, b); } Because it's probably overkill. At some point it becomes too much magic. The following currently works but it might be considered an ambiguity with return type inference: - struct S { int get() { return 0; } T get(T)() { return T.init; } } void main() { S s; float x = s.get(); // which overload? (currently int get()) } -
Re: Converting function pointers to delegates
On 4/15/14, Artur Skawina art.08...@gmail.com wrote: It *is* true. Classes are /reference types/, not references to classes. I meant the part where he said you can't cast a reference to a pointer. You can.
Re: aliases and .stringof
On 4/15/14, Dicebot pub...@dicebot.lv wrote: In general .stringof output is not defined by spec and is not guaranteed to stay same between releases. The spec mentions this as well: http://dlang.org/property.html#stringof Quote: - Note: Using .stringof for code generation is not recommended, as the internal representation of a type or expression can change between different compiler versions. Instead you should prefer to use the identifier trait, or one of the Phobos helper functions such as fullyQualifiedName. -
Re: Converting function pointers to delegates
On 4/15/14, Artur Skawina art.08...@gmail.com wrote: He obviously meant that you can't get a pointer to the object, that the reference points to, just by casting and w/o address-of. Ah right. I don't do this often so I forgot. The proper code would be: int* f(ref int r) { return r; }
Re: Converting function pointers to delegates
On Monday, 14 April 2014 at 17:48:31 UTC, Adam D. Ruppe wrote: On Monday, 14 April 2014 at 17:45:52 UTC, Ryan Voots wrote: src/yage/core/misc.d(164): Error: e2ir: cannot cast this of type S to type void* Try taking the address of this before casting it. So more like cast(void*)this IIRC in D1 this was a pointer, whereas in D2 this is a reference. You can't cast a reference to pointer directly. That's not true. And I think the issue in his diagnostic is that he used it with a struct. You can't cast 'this' of a struct to a pointer (you'd have to use this), but you can cast a class reference to a pointer.
Re: Converting function pointers to delegates
On Monday, 14 April 2014 at 17:45:52 UTC, Ryan Voots wrote: /** * Convert any function pointer to a delegate. * _ From: http://www.digitalmars.com/d/archives/digitalmars You can replaced it with std.functional.toDelegate. As for its use-case, if some API or function supports only delegates but you want to pass in a function, you would wrap the function with toDelegate and then pass the delegate to the API/function.
Re: sending a delegate through extern (C)
On Thursday, 27 March 2014 at 00:46:33 UTC, Etienne wrote: Hi, I'm trying to send a delegate to a modified version of druntime's GC as follows: struct GC { static void onCollect(void* dg) { gc_onCollect(cast(void*)dg); } There isn't enough information here to extract what's going on in your code.
Re: ambiguous definition
On Monday, 10 March 2014 at 22:45:36 UTC, Pasqui23 wrote: Hi. I was editing std.string,but when I tried to compile it it game me this error: One of the errors in git-head is: test.d(553): Error: undefined identifier S Check your constraints, isSomeString!S should have been isSomeString!S1 or isSomeString!S2.
Re: build dustmite
On Sunday, 9 March 2014 at 12:14:43 UTC, bioifornatics wrote: Firstly build way describe at https://github.com/CyberShadow/DustMite/wiki/Building-DustMite seem to be wrong as dsplit.d was rename as splitter.d Anyone can edit the wiki. But this was fixed now. Secondly build fail take a look behind $ ldc2 -release -w -g -O3 dustmite.d splitter.d -of dustmite splitter.d(262): Error: delegate splitter.DSplitter.__lambda22 function literals cannot be class members splitter.d(284):called from here: (*_error_() From what i can tell line 284 references pull 2824, which was merged just recently. Dustmite likely requires a git-head version of the compiler. Probably an oversight. A pull was made to fix the issue: https://github.com/CyberShadow/DustMite/pull/19 In the future you should really file bugs to the dustmite bug tracker, not D.learn.
Re: Problem with escaping commands in spawProcess().
On Friday, 7 March 2014 at 09:26:27 UTC, Cooler wrote: import std.process; int main(string[]){ // Next line will generate error message from cmd.exe spawnProcess([cmd.exe, /C, echo]).wait(); return 0; } I'm not sure, but maybe file a bug so this gets some attention: https://issues.dlang.org/enter_bug.cgi?product=D
Re: function name inside a funciton
On 4/12/14, user u...@user.com wrote: Never mind, just discovered __PRETTY_FUNCTION__. Yes and there's also __FUNCTION__. Philippe Sigaud's book[1] had a nice trick of extracting the current function name with a single template instantiation, but I can't find it in his template book. There's a Local Scope Name chapter, but I distinctly remember something which was a single template call.. hmm.. it might have changed in recent versions. [1] : https://github.com/PhilippeSigaud/D-templates-tutorial
Re: Local function overloading
On 4/12/14, monarch_dodra monarchdo...@gmail.com wrote: I know you can workaround it by putting your functions a static members of a dummy struct You can also use a mixin template: class A {} class B {} mixin template M() { void func2(A a) { } void func2(B b) { } } void main() { mixin M!(); func2(new A); func2(new B); }
Re: Extracting Params of Templated Type
On 4/4/14, Meta jared...@gmail.com wrote: alias TemplateArgs(T: Foo!U, U) = U; It's also in std.traits, TemplateArgsOf, which is more complete.
Re: Signature of main [was Sockets between D and C(++) app]
On 4/2/14, Dicebot pub...@dicebot.lv wrote: D main != C main, latter is implemented in D runtime to call the former. 0 will be also returned by latter, not the former. Actually, the compiler injects a return statement in D's main. It generates the actual C main function (unless WinMain/DllMain is provided), which calls another special D runtime init function, which itself calls the D main function (which itself has the injected return statement unless it's already an int return). It's quite complicated, but it's all open-source so you can inspect it.
Re: Why are compile-time constraints checked with an (inout int = 0) lambda in Phobos?
On 3/27/14, Atila Neves atila.ne...@gmail.com wrote: Why the (inout int = 0) instead of an empty parameter list? Try removing it and compile std.range with -unittest. Here's what happens: std\range.d(546): Error: static assert (isInputRange!(inout(int)[])) is false The reason it's false is because the code wouldn't compile. Here's a test-case: - import std.array; void test() { inout(int)[] r = (inout(int)[]).init; if (r.empty) {} r.popFront(); auto h = r.front; } void main() { test(); } - test.d(7): Error: variable test.test.r inout variables can only be declared inside inout functions So you need to add inout in the parameter list to avoid this compiler error and to make your function work with any qualified range type.
Re: is there any trait to check if variable is __gshared?
On 3/26/14, ketmar nobodyherethismailsu...@gmail.com wrote: is there any trait to check if variable is __gshared? typeof() for '__gshared int' returns just 'int', whereas for 'shared int' it returns 'shared(int)'. can i check for __gshared storage class somehow? Please file this as an enhancement request to bugzilla[1]. Thanks! [1] : https://d.puremagic.com/issues/enter_bug.cgi?product=D
Re: is there any trait to check if variable is __gshared?
On 3/26/14, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Please file this as an enhancement request to bugzilla[1]. Thanks! [1] : https://d.puremagic.com/issues/enter_bug.cgi?product=D Ok filed as: https://d.puremagic.com/issues/show_bug.cgi?id=12474
Re: Exception error message without stacktrace
On Tuesday, 25 March 2014 at 14:43:18 UTC, Spacen Jasset wrote: I caught a FileException, and want to print out the descriptive error, but not the stacktrace. Try writing the exception's 'msg' field (it's a string). There is also 'file' and 'line'. See the class Throwable (in object.d or object.di) and the FileException class in std.file (it has some additional fields like errno).
Re: Combining template parameters deduction with default template parameters
On 3/23/14, Uranuz neura...@gmail.com wrote: I have a question how I could combine template parameters deduction with setting default values for template parameters. I will start directly from a piece of code. You can use eponymous templates for this. E.g.: - template decodeURICustom(string allowedSpecChars = null, bool formEncoding = false) { string decodeURICustom(T)(T source) pure { return ; } } alias decodeURICustom!(!$'()*+,;=) decodeURIHost; void main() { string str= http://www.dlang.org;; string result = decodeURICustom(str); } -
Re: Check for presence of function
On 3/23/14, Philippe Sigaud philippe.sig...@gmail.com wrote: But this is not accepted by the grammar right now, because of __traits() Pretty sure it's because you're using 'alias' instead of 'enum'. This works: - enum isSomething(T) = __traits(compiles, { int up; T.init.doSomething(up); } ); void main() { static struct S { void doSomething(int); } static struct X { void doSomething(string); } static assert(isSomething!S); static assert(!isSomething!X); } -
Re: Check for presence of function
On 3/23/14, Philippe Sigaud philippe.sig...@gmail.com wrote: Now, if only __traits could be beautified somewhat... I mean: everyone is using it, it's time to make it more palatable. That's what std.traits is for, to hide the __traits and is() uglyness.
Re: reflection over templates
On 3/19/14, Adam D. Ruppe destructiona...@gmail.com wrote: Is there anything we can do with static if to identify it as a template? https://github.com/D-Programming-Language/dmd/pull/3380 And after we determine it is a template, can we extract the required arguments list like we can with a regular function at all? Well there's TemplateArgsOf for *instantiations*, but I'm not sure how one would do it with non-instantiations. In particular how would we create a tuple of template parameter types where one of the parameters was an alias? E.g.: template Foo(int, alias X); alias Args = TypeTuple!(int, ???); There is no alias type you could use in this case.
Re: Just-run-the-unittests
On 3/16/14, Sergei Nosov sergei.no...@gmail.com wrote: Thx! That's better, but I think -main switch could be made to work like 'add or replace main by stub' instead of just 'add'. I don't think it'll hurt anybody, what do you think? It can't work, because main could be stored in a pre-built object or static library that's passed to DMD.
Re: Memory errors
On 3/16/14, PhilE theotherp...@hotmail.com wrote: When using both simpleimage and DWT my program crashes with core.exception.InvalidMemoryOperationError It's likely something is trying to allocate in a destructor.
Re: Non-Initialized Dynamic Arrays Construction
On 2/24/14, bearophile bearophileh...@lycos.com wrote: The OP wants minimallyInitializedArray. uninitializedArray is only for special situations. There needs to be a ddoc-ed sample demonstrating *exactly* what the difference between minimallyInitializedArray and uninitializedArray is.
Strange result with nextUp for reals
- import std.math; import std.stdio; void main() { writefln(nextUp of %a is %a, 1.0, 1.0.nextUp()); real num = 1.0; writefln(nextUp of %a is %a, num, num.nextUp()); } - This prints: nextUp of 0x1p+0 is 0x1.1p+0 nextUp of 0x1p+0 is 0x1.0002p+0 Any idea why the results are different?
Re: Strange result with nextUp for reals
On 2/16/14, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Any idea why the results are different? Interestingly the literal versions end up calling nextUp which takes a double rather than a real. So nextUp(1.0) calls the double overload, nextUp(num) calls the real overload. Mystery solved.
Re: @trusted delegates all over std.array
On Sunday, 2 February 2014 at 17:40:47 UTC, TheFlyingFiddle wrote: Why is std.array litered with @trusted delegates? IIRC these were added in the last few releases to make code CTFE-able or to allow pure code to call such functions. A lot of array/string-processing code wasn't usable from CTFE/pure, this was one workaround to the problem.
Re: @trusted delegates all over std.array
On 2/2/14, Jesse Phillips jesse.k.phillip...@gmail.com wrote: Pretty sure @trusted only affect the use of @safe and never makes CTFE work. This is what I remember, it has a huge diff and has lots of these trusted lambdas in it: https://github.com/D-Programming-Language/phobos/pull/1337/files
Re: std.array.array broken?
On Saturday, 1 February 2014 at 22:47:54 UTC, deed wrote: Docs say: - std.stdio.byLine returns an input range - std.array.array takes an input range Docs also say: /** Note: Each $(D front) will not persist after $(D popFront) is called, so the caller must copy its contents (e.g. by calling $(D to!string)) if retention is needed. */ So you need to do a duplication for each element. Use this code: - import std.stdio; import std.array; import std.algorithm; void main() { auto lines = File(test.d).byLine.map!(a = a.dup).array; writeln(lines); } -
Re: I don't even..
On 1/31/14, Meta jared...@gmail.com wrote: You might want to file a bug report as well about the utterly obtuse error message. Yes, please file this as a bug. Thanks!
Re: Symbol undefined
On Thursday, 30 January 2014 at 21:28:08 UTC, Martijn Pot wrote: Error 42: Symbol Undefined _D1a14Transmogrifier12transmogrifyMFZv (void a.Transmogrifier.transmogrify()) Typically that means the function isn't implemented, e.g. this: void transmogrify(); instead of this: void transmogrify() { } The NVI examples in TDPL don't really work, as private functions in D are currently not virtual. You could try pasting example code of what you're trying to build to show you exactly what goes wrong.
Re: Symbol undefined
On 1/30/14, Martijn Pot martijnpo...@gmail.com wrote: Indeed, making them public solved the problem. Is there more stuff in the book that isn't working? Check the errata page[1], which coincidentally seems to be down. I'll CC Andrei. [1]: http://erdani.com/tdpl/errata/index.php?title=Main_Page Another more-recent book (and a free one) is this: http://ddili.org/ders/d.en/index.html
Re: Symbol undefined
On 1/30/14, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 1/30/14, Martijn Pot martijnpo...@gmail.com wrote: Indeed, making them public solved the problem. Is there more stuff in the book that isn't working? Check the errata page[1], which coincidentally seems to be down. I'll CC Andrei. [1]: http://erdani.com/tdpl/errata/index.php?title=Main_Page Another more-recent book (and a free one) is this: http://ddili.org/ders/d.en/index.html I CC'ed the wrong address, re-sending.
Re: A possible enhancement related to is()
On 1/29/14, Jakob Ovrum jakobov...@gmail.com wrote: On a related note, I would like the body of a template to be able to access aliases introduced in IsExpression's in the template's constraints. Me too, but I can't remember if this was filed in bugzilla.
Re: Keywords: How to trick the compiler?
On 1/28/14, Chris wend...@tcd.ie wrote: Is there a simple way to trick the compiler (e.g. with alias), if a keyword conflicts with a function/method, e.g. as in a HTML document: auto docBody = document.body; body is probably the most frequent issue I run into when porting C/C++ code to D. I really wonder whether the rule could be relaxed a little bit.
Re: Array of pointers
On 1/16/14, Philippe Sigaud philippe.sig...@gmail.com wrote: The thing is, an array is a reference type Actually it's not, let's not confuse people with the terminology here. To recap for people new to arrays: an array in D is really just a struct, e.g.: struct Array { int* data; size_t length; } Array myArray; Once you know this it's easy to understand why passing myArray by value to a function allows you to change the contents of data, but changing what data points to or changing the length of the array will not be reflected at the call site, *unless* you've passed myArray to a function by reference.
Re: Simplest way to create an array from an associative array which its contains keys and values?
On 1/7/14, Craig Dillabaugh cdill...@cg.scs.carleton.ca wrote: In other words while: auto range = aa.byKey.map!(a = chain(a.only, aa[a].only)); string[] array = range.join; Saves a few lines of code, and looks cooler, it seems that the trivial foreach loop version is very easy: string[] array; foreach (key, value; aa) { array ~= key; array ~= value; } OP asked for an array, however the reason I showed the example is because you can get a range that way, which is lazy and will not allocate: auto items = aa.byKey.map!(a = chain(a.only, aa[a].only)).joiner; // no allocations at all writeln(items); So there's a huge difference, as you're saving memory (and CPU time if you don't want to walk through the entire list).
Re: Simplest way to create an array from an associative array which its contains keys and values?
On Friday, 3 January 2014 at 17:38:16 UTC, Gary Willoughby wrote: I know it can be done via a loop, but is there a more idiomatic way to achieve this? import std.algorithm; import std.range; import std.stdio; void main() { auto aa = [one:1, two:2]; auto range = aa.byKey.map!(a = chain(a.only, aa[a].only)); string[] array = range.join; writeln(array); } However I'm not sure whether only is present in 2.064, maybe it was added recently in the git-head version.
Re: Simplest way to create an array from an associative array which its contains keys and values?
On Friday, 3 January 2014 at 17:47:43 UTC, bearophile wrote: string[] r = aa.byKey.map!(k = [k, aa[k]]).join; However the [k, aa[k]] expression will allocate an array for each key you iterate over regardless if you use join or joiner. I posted a solution with only, hope that works. :)
Re: Human stupidity or is this a regression?
On 12/26/13, bearophile bearophileh...@lycos.com wrote: You have to explain such things in the main D newsgroup. D.learn newsgroup is not fit for such requests. There have already been a million of these threads, it's worth doing a search as there's probably lots of answers there.
Re: Compilation depends on class methods order
On 12/20/13, Jacob Carlborg d...@me.com wrote: You cannot overload a standard function with a template function, or has that been fixed? That was fixed in 2.064+
Re: Compilation depends on class methods order
On 12/20/13, kdmult kdm...@ya.ru wrote: But why the order of the declarations has an effect on the compilation result. I think you should file this as a bug.
Re: Compilation depends on class methods order
On 12/20/13, Jacob Carlborg d...@me.com wrote: On 2013-12-20 09:42, Andrej Mitrovic wrote: That was fixed in 2.064+ Cool, finally :) Yeah, it caused many headaches. Fixed thanks to Kenji, of course (who else?).
Re: package.d
On 12/17/13, Leandro Motta Barros l...@stackedboxes.org wrote: Is there any documentation describing the expected to behavior in regard to the fully-qualified names of the publicly imported symbols in package.d? It might have been an oversight, but we'll have to wait for (I think Kenji) to reply since he implemented packages.
std.regex literal syntax (the \Q…\E escape sequence)
I'm reading through http://www.regular-expressions.info, and there's a feature that's missing from std.regex, quoted: - All the characters between the \Q and the \E are interpreted as literal characters. E.g. \Q*\d+*\E matches the literal text *\d+*. The \E may be omitted at the end of the regex, so \Q*\d+* is the same as \Q*\d+*\E. - This would translate to the following needing to work (which fails at runtime with an exception): writeln(r*\d+*.match(r\Q*\d+*\E)); Should this feature be added? I guess there's probably more regex features missing (I just began reading the page), I'm not sure how Dmitry feels about adding X number of features though.
Re: std.regex literal syntax (the \Q…\E escape sequence)
On 12/18/13, Dmitry Olshansky dmitry.o...@gmail.com wrote: By the end of day any feature is interesting as long as we carefully weight: - how useful a feature is - how widespread the syntax/how many precedents in other libraries against - how difficult to implement - does it affect backwards compatibility - any other hidden costs I'd be glad to implement well motivated enhancement requests. Excellent, that's what I'm hoping for from any library dev. Weigh the odds before adding random features. :)
Re: std.regex literal syntax (the \Q…\E escape sequence)
On 12/18/13, Dmitry Olshansky dmitry.o...@gmail.com wrote: P.S. This reminds me to put a roadmap of sorts on where std.regex is going and what to expect. Btw one thing I'm not fond of is the format specifiers, in particular: $` part of input preceding the match. $' part of input following the match. ` and ' are very hard to tell apart. But I guess this was based on an existing standard? Personally I'd prefer $ and $.
Re: std.regex literal syntax (the \Q…\E escape sequence)
On 12/18/13, Dmitry Olshansky dmitry.o...@gmail.com wrote: The precedent is Perl. A heavy influencer on the (former) std.regex design. http://perldoc.perl.org/perlre.html#Capture-groups (grep for $') Ah, classic Perl. Write once - don't bother to read ever again. :p
Re: Shouldn't SList in std.container hold an owner pointer to verify a range belongs to the list?
On 12/17/13, monarch_dodra monarchdo...@gmail.com wrote: Didn't I reply to this already? dlang.org was down recently, maybe the forum was as well. :) Anyways... what I said is that we can add the test in non-release, but I see it as assertive code, so it can be removed in release. Sure: version(assert) SList owner; Works for me. I'd be more afraid of DList's current semantics: Neither value nor ref. I've been trying to fix it for more than a year now: https://github.com/D-Programming-Language/phobos/pull/953 I'll take a look.
Shouldn't SList in std.container hold an owner pointer to verify a range belongs to the list?
Here's some improper code that is not checked properly by SList (meaning no assertions, not even in debug mode): - import std.stdio; import std.container; void main() { auto s1 = SList!string([a, b, d]); auto s2 = SList!string([a, b, d]); // note the s1[] instead of s2[]! s2.insertAfter(std.range.take(s1[], 2), c); writeln(s1[]); // updated s1, not s2! writeln(s2[]); // s2 stays the same. } - Note the docs of insertAfter: Inserts $(D stuff) after range $(D r), which must be a range previously extracted from this container. Well clearly we have a range extracted from one list being used to add items to a different list, but SList makes no checks at all to verify the range belongs to it. I had a look at DCollections[1], and it stores an owner pointer (or reference) in the range type when its extracted from a linked-list, so it can do these types of sanity checks. So shouldn't we add this to SList? We'd have to add an owner field to its internal Range struct. [1] : https://github.com/schveiguy/dcollections
Re: Custom Exponents
On 12/15/13, Philippe Sigaud philippe.sig...@gmail.com wrote: http://dlang.org/phobos/std_math.html#.pow See the fourth overload: `if (isFloatingPoint!F isFloatingPoint!G)`. Is there any difference between using `a ^^ b` and `pow(a,b)`? Depends on whether the arguments are known at compile-time, and their type. And in fact.. constant folding also affects what works regardless of what you type something with, so initializers are taken into account. Some demonstrations: - void main() { int a = 2, b = 2; auto c = a ^^ b; } - test.d(6): Error: must import std.math to use ^^ operator The following will work though, probably through some compiler intrinsic: - void main() { enum a = 2, b = 2; auto c = a ^^ b; } - Here's where things get interesting. The following works: - void main() { enum float a = 1.0; enum float b = 2.1; auto c = a ^^ b; } - But the following doesn't: - void main() { enum float a = 1.1; // note the .1 change enum float b = 2.1; auto c = a ^^ b; } - So even if you type something as `enum float a = 1.0`, the compiler will be able to implicitly convert it to an int and it will make the call work. It seems like the intrinsic supports int^^int, int^^float, and float^^int, but not float^^float. Side-note: Importing std.stdio implicitly imports std.math, so you won't have any errors (boy do I hate public imports where they don't belong..).
Re: Access violation error using Derelict GL3
On 12/15/13, Ross Hays t...@gmail.com wrote: Am I doing something wrong here? You're likely not loading the function pointers first. Try calling DerelictGL.reload() first.
Re: Cannot pass by reference
On 11/17/13, Ali Çehreli acehr...@yahoo.com wrote: It allows changing the actual object that the caller had. Technically no, it changes the reference in the caller, not the actual object itself. That object is likely still alive until collected if there are no other references to it.
Re: Compile-time sets and hash tables
On 11/14/13, Philippe Sigaud philippe.sig...@gmail.com wrote: - I'd greatly like for those sets or hash tables to be CTFE-compatible. Well if it's only used in CTFE, I'd imagine a simple struct wrapping an array and doing !canFind when adding elements would do the job, no?
Re: The D Programming Language page 161.
On 11/13/13, Adam D. Ruppe destructiona...@gmail.com wrote: On Wednesday, 13 November 2013 at 08:16:34 UTC, Tor Einar Tønnessen wrote: void writeln(string a0, int a1, string a2, int[new] a3) { Around the time the book was written, there was a debate as to if we should make dynamic arrays and slices two different types. T[new] was the proposed syntax for a dynamic array, leaving T[] to be a slice. I think it was just an oversight that it was left in the book, I don't recall reading about that syntax on any other page.
Re: Array Defenitions
On 11/13/13, Jeroen Bollen jbin...@gmail.com wrote: I feel there is a lack of resources/documentation on array definitions. I cannot believe the official documentation tries to explain how D handles arrays without defining an array a single time. http://dlang.org/arrays.html See if this helps: http://dlang.org/d-array-article.html