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

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!

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: 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!

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?

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: 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-t

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-t

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

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

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.

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: 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

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: 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: 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: 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: 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

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: 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: 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, 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, 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: 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: 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: __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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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, 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: 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: 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: 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: Converting function pointers to delegates

2014-04-15 Thread Andrej Mitrovic
On 4/15/14, Artur Skawina 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: aliases and .stringof

2014-04-15 Thread Andrej Mitrovic
On 4/15/14, Dicebot 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 intern

Re: Converting function pointers to delegates

2014-04-15 Thread Andrej Mitrovic
On 4/15/14, Artur Skawina 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: Converting function pointers to delegates

2014-04-14 Thread Andrej Mitrovic
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

Re: Converting function pointers to delegates

2014-04-14 Thread Andrej Mitrovic
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 i

Re: Problem with escaping commands in spawProcess().

2014-04-13 Thread Andrej Mitrovic
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

Re: build dustmite

2014-04-13 Thread Andrej Mitrovic
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

Re: ambiguous definition

2014-04-13 Thread Andrej Mitrovic
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

Re: sending a delegate through extern (C)

2014-04-13 Thread Andrej Mitrovic
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

Re: Local function overloading

2014-04-12 Thread Andrej Mitrovic
On 4/12/14, monarch_dodra 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!(); func

Re: function name inside a funciton

2014-04-11 Thread Andrej Mitrovic
On 4/12/14, user 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

Re: Extracting Params of Templated Type

2014-04-04 Thread Andrej Mitrovic
On 4/4/14, Meta 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]

2014-04-02 Thread Andrej Mitrovic
On 4/2/14, Dicebot 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), w

Re: Why are compile-time constraints checked with an (inout int = 0) lambda in Phobos?

2014-03-28 Thread Andrej Mitrovic
On 3/27/14, Atila Neves 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

Re: is there any trait to check if variable is __gshared?

2014-03-26 Thread Andrej Mitrovic
On 3/26/14, Andrej Mitrovic 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: is there any trait to check if variable is __gshared?

2014-03-26 Thread Andrej Mitrovic
On 3/26/14, ketmar 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]. T

Re: Exception "error" message without stacktrace

2014-03-25 Thread Andrej Mitrovic
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 obje

Re: Check for presence of function

2014-03-23 Thread Andrej Mitrovic
On 3/23/14, Philippe Sigaud 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: Check for presence of function

2014-03-23 Thread Andrej Mitrovic
On 3/23/14, Philippe Sigaud 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)

Re: Combining template parameters deduction with default template parameters

2014-03-23 Thread Andrej Mitrovic
On 3/23/14, Uranuz 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 allowedSpecCh

Re: reflection over templates

2014-03-19 Thread Andrej Mitrovic
On 3/19/14, Adam D. Ruppe 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 > a

Re: Memory errors

2014-03-16 Thread Andrej Mitrovic
On 3/16/14, PhilE 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: Just-run-the-unittests

2014-03-16 Thread Andrej Mitrovic
On 3/16/14, Sergei Nosov 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 libra

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Andrej Mitrovic
On 2/24/14, bearophile 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.

Re: Strange result with nextUp for reals

2014-02-16 Thread Andrej Mitrovic
On 2/16/14, Andrej Mitrovic 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.

Strange result with nextUp for reals

2014-02-16 Thread Andrej Mitrovic
- 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

Re: std.random.uniform for enums

2014-02-12 Thread Andrej Mitrovic
On 2/13/14, Anton wrote: > It would be useful if someone added this as an example to the > docs, so that beginners don't end up in the same situation as me > in the future. My mistake for not adding an example when implementing the function. Here we go: https://github.com/D-Programming-Language/

Re: @trusted delegates all over std.array

2014-02-02 Thread Andrej Mitrovic
On 2/2/14, Jesse Phillips 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: @trusted delegates all over std.array

2014-02-02 Thread Andrej Mitrovic
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 CTF

Re: std.array.array broken?

2014-02-01 Thread Andrej Mitrovic
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 $(

Re: I don't even..

2014-01-31 Thread Andrej Mitrovic
On 1/31/14, Meta 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

2014-01-30 Thread Andrej Mitrovic
On 1/30/14, Andrej Mitrovic wrote: > On 1/30/14, Martijn Pot 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 > Andre

Re: Symbol undefined

2014-01-30 Thread Andrej Mitrovic
On 1/30/14, Martijn Pot 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

Re: Symbol undefined

2014-01-30 Thread Andrej Mitrovic
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(

Re: A possible enhancement related to is()

2014-01-29 Thread Andrej Mitrovic
On 1/29/14, Jakob Ovrum 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?

2014-01-28 Thread Andrej Mitrovic
On 1/28/14, Chris 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

Re: Array of pointers

2014-01-20 Thread Andrej Mitrovic
On 1/16/14, Philippe Sigaud 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

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-07 Thread Andrej Mitrovic
On 1/7/14, Craig Dillabaugh 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; >

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-05 Thread Andrej Mitrovic
On 1/5/14, bearophile wrote: > Perhaps the "s" suffix (to define fixed-sized arrays) could avoid > that problem: > > string[] r = aa.byKey.map!(k => [k, aa[k]]s).join; I would prefer a prefix though, to make it immediately obvious you're creating a static array. string[] r = aa.byKey.map!(k => s

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-03 Thread Andrej Mitrovic
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: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-03 Thread Andrej Mitrovic
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.ma

Re: Human stupidity or is this a regression?

2013-12-26 Thread Andrej Mitrovic
On 12/26/13, bearophile 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

2013-12-20 Thread Andrej Mitrovic
On 12/20/13, Jacob Carlborg 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: Compilation depends on class methods order

2013-12-20 Thread Andrej Mitrovic
On 12/20/13, kdmult 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

2013-12-20 Thread Andrej Mitrovic
On 12/20/13, Jacob Carlborg wrote: > You cannot overload a standard function with a template > function, or has that been fixed? That was fixed in 2.064+

Re: std.regex literal syntax (the \Q…\E escape sequence)

2013-12-18 Thread Andrej Mitrovic
On 12/18/13, Dmitry Olshansky 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: std.regex literal syntax (the \Q…\E escape sequence)

2013-12-18 Thread Andrej Mitrovic
On 12/18/13, Dmitry Olshansky 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. `

Re: std.regex literal syntax (the \Q…\E escape sequence)

2013-12-18 Thread Andrej Mitrovic
On 12/18/13, Dmitry Olshansky 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 compati

std.regex literal syntax (the \Q…\E escape sequence)

2013-12-18 Thread Andrej Mitrovic
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 reg

Re: package.d

2013-12-18 Thread Andrej Mitrovic
On 12/17/13, Leandro Motta Barros 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 implement

Re: Shouldn't SList in std.container hold an owner pointer to verify a range belongs to the list?

2013-12-17 Thread Andrej Mitrovic
On 12/17/13, monarch_dodra 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

Shouldn't SList in std.container hold an owner pointer to verify a range belongs to the list?

2013-12-16 Thread Andrej Mitrovic
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 s

Re: Access violation error using Derelict GL3

2013-12-15 Thread Andrej Mitrovic
On 12/15/13, Ross Hays wrote: > Am I doing something wrong here? You're likely not loading the function pointers first. Try calling DerelictGL.reload() first.

Re: Custom Exponents

2013-12-15 Thread Andrej Mitrovic
On 12/15/13, Philippe Sigaud 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 the

Re: Cannot pass by reference

2013-11-17 Thread Andrej Mitrovic
On 11/17/13, Ali Çehreli 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

2013-11-14 Thread Andrej Mitrovic
On 11/14/13, Philippe Sigaud 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?

  1   2   3   4   5   6   7   8   9   10   >