Re: chain of exceptions, next method

2022-09-10 Thread Andrej Mitrovic via Digitalmars-d-learn
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

What is the point of a synchronized lock on a single return statement?

2019-11-25 Thread Andrej Mitrovic via Digitalmars-d-learn
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

Why is time_t defined as a 32-bit type on Windows?

2020-08-05 Thread Andrej Mitrovic via Digitalmars-d-learn
``` 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, equiv

Re: Why is time_t defined as a 32-bit type on Windows?

2020-08-05 Thread Andrej Mitrovic via Digitalmars-d-learn
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-20

Re: Why is time_t defined as a 32-bit type on Windows?

2020-08-06 Thread Andrej Mitrovic via Digitalmars-d-learn
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-20

How do I convert an ISO 8601 datetime into a unix timestamp - at compile-time?

2020-08-27 Thread Andrej Mitrovic via Digitalmars-d-learn
- 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/concurre

Re: How do I convert an ISO 8601 datetime into a unix timestamp - at compile-time?

2020-08-27 Thread Andrej Mitrovic via Digitalmars-d-learn
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?

Re: How do I convert an ISO 8601 datetime into a unix timestamp - at compile-time?

2020-08-30 Thread Andrej Mitrovic via Digitalmars-d-learn
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!

A function to split a range into several ranges of different chunks

2020-09-14 Thread Andrej Mitrovic via Digitalmars-d-learn
- 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.???(

Re: A function to split a range into several ranges of different chunks

2020-09-14 Thread Andrej Mitrovic via Digitalmars-d-learn
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!

Anyone have a Vibe.d Diet Template syntax definition for Sublime?

2019-04-21 Thread Andrej Mitrovic via Digitalmars-d-learn
Or perhaps for any other editor so I could adapt it and have syntax highlighting in Sublime when viewing .dt files.

Re: Anyone have a Vibe.d Diet Template syntax definition for Sublime?

2019-04-21 Thread Andrej Mitrovic via Digitalmars-d-learn
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.

Re: Linker error

2016-06-05 Thread Andrej Mitrovic via Digitalmars-d-learn
On 6/5/16, Anonymous via Digitalmars-d-learn wrote: > 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 d

Re: Linker error

2016-06-05 Thread Andrej Mitrovic via Digitalmars-d-learn
On 6/5/16, Anonymous via Digitalmars-d-learn wrote: > 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 to

Re: Speed up `dub`.

2016-06-05 Thread Andrej Mitrovic via Digitalmars-d-learn
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.. tha

Re: Asio Bindings?

2016-06-08 Thread Andrej Mitrovic via Digitalmars-d-learn
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.. meanin

Re: Asio Bindings?

2016-06-10 Thread Andrej Mitrovic via Digitalmars-d-learn
On 6/9/16, Joerg Joergonson via Digitalmars-d-learn 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 wrote: > Hello, > > I'm currently porting the Steinberg VST and ASIO SDKs for use with the

Re: Struct size

2014-04-19 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/19/14, Lars T. Kyllingstad via Digitalmars-d-learn 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 a

Re: Template method and type resolution of return type

2014-04-19 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/19/14, matovitch via Digitalmars-d-learn 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 m

Re: std.file.read returns void[] why?

2014-04-20 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/18/14, monarch_dodra via Digitalmars-d-learn 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

Re: Named template constraints

2014-04-22 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/22/14, Tim Holzschuh via Digitalmars-d-learn 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()?

2014-04-22 Thread Andrej Mitrovic via Digitalmars-d-learn
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

2014-04-22 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/22/14, Steven Schveighoffer via Digitalmars-d-learn > I think this can be fixed a different way. Feel free to file a bug / make a pull. :>

Re: Partial ordering of constructors with type parameters

2014-04-24 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/24/14, monarch_dodra via Digitalmars-d-learn wrote: > *That* creates a conflict though :/ Are you sure? I can't reproduce.

Re: Another bug in function overloading?

2014-04-26 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/26/14, Jonathan M Davis via Digitalmars-d-learn 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: Can I circumvent nothrow?

2014-04-27 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/27/14, Damian Day via Digitalmars-d-learn wrote: > So I have this procedure. Have a look at std.exception.assumeWontThrow: http://dlang.org/phobos/std_exception.html#.assumeWontThrow

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Andrej Mitrovic via Digitalmars-d-learn
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: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/28/14, ParticlePeter via Digitalmars-d-learn 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

Re: private constructors and inheritance

2014-04-29 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/29/14, Dicebot via Digitalmars-d-learn 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: formattedWrite writes nothing

2014-05-02 Thread Andrej Mitrovic via Digitalmars-d-learn
On 5/2/14, ref2401 via Digitalmars-d-learn 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

Re: Is it possible to check if a type is an instance of a template?

2014-05-06 Thread Andrej Mitrovic via Digitalmars-d-learn
On 5/6/14, bearophile via Digitalmars-d-learn 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: derelict glfw won't set callbacks

2014-05-24 Thread Andrej Mitrovic via Digitalmars-d-learn
On 5/24/14, Vlad Levenfeld via Digitalmars-d-learn 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 be

Re: enums

2014-05-31 Thread Andrej Mitrovic via Digitalmars-d-learn
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

Re: assocArray.get(key, default) exists?

2014-06-21 Thread Andrej Mitrovic via Digitalmars-d-learn
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

2014-06-21 Thread Andrej Mitrovic via Digitalmars-d-learn
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: __VERSION__ and the different compilers

2014-07-09 Thread Andrej Mitrovic via Digitalmars-d-learn
On 7/9/14, Mike Parker via Digitalmars-d-learn 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: Strange segfault (Derelict/OpenGL)

2014-08-29 Thread Andrej Mitrovic via Digitalmars-d-learn
On 8/29/14, Robin Schroer via Digitalmars-d-learn 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: Access Violation Tracking

2014-11-06 Thread Andrej Mitrovic via Digitalmars-d-learn
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 calli

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Idan Arye via Digitalmars-d-learn 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?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Peter Alexander via Digitalmars-d-learn 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 s

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, H. S. Teoh via Digitalmars-d-learn 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/

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Tobias Pankrath via Digitalmars-d-learn 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: Static if to compare two types are the exact same

2015-04-06 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/6/15, Jonathan via Digitalmars-d-learn 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

Re: Array start index

2015-08-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 8/1/15, DLearner via Digitalmars-d-learn 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/arch