Re: AA struct hashing bug?

2015-12-07 Thread ketmar via Digitalmars-d-learn
worksforme. git HEAD, GNU/Linux, x86.

Re: AA struct hashing bug?

2015-12-09 Thread ketmar via Digitalmars-d-learn
heh. it crashed due to "in" presence. if you'll remove "in", it will work.

Re: Is it possible to "cache" results of compile-time executions between compiles?

2017-01-24 Thread ketmar via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 12:14:05 UTC, TheFlyingFiddle wrote: unittest { enum s = import("myfile"); } Is there something similar to this for outputting files at compile-time? no. this is by design, so it won't be fixed. sorry. you may use build script that will create the code

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
Ali Çehreli wrote: Correction: It's actually the 'auto attribute' in D with the venerable responsibility of "The auto attribute is used when there are no other attributes and type inference is desired." Good job, auto! :o) foreach (auto n; arr) oops. good job, auto!

Re: Force inline

2017-02-20 Thread ketmar via Digitalmars-d-learn
H. S. Teoh wrote: Having said all that, though, have you used a profiler to determine whether or not your performance bottleneck is really at the function in question? I find that 90% of the time what I truly believe should be inlined actually doesn't make much difference; the bottleneck is

Re: Class Order Style

2017-02-20 Thread ketmar via Digitalmars-d-learn
Jolly James wrote: How to sort the members of a class? like: 1. properties then 2. private 3. methods 4. ctors ... and so on. are there any recommendations? And what is better? just add ddoc documentation to 'em, and then it doesn't matter in which order they are declared: people will

Re: Force inline

2017-02-20 Thread ketmar via Digitalmars-d-learn
Moritz Maxeiner wrote: I don't know, but I'd guess that the length of a function is not as important for the consideration of being inlined as its semantics. yep. basically, dmd doesn't like anything other than very simple if/else conditions. sometimes it likes if (cond0) return n0; else if

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: Suppose I have a simple 2 x 3 array like so: import std.stdio; import std.range: iota; void main() { // a 2 x 3 array int [3][2] arr; foreach (i; iota(0, 2)) { foreach(j; iota(0, 3)) { arr[i][j] = i+j; }

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: Very interesting reading about your experiences! tnx. ;-) one thing I've observed is that so far (very very early of course) D appears to be a lot more intuitive than C++ yeah. i almost finished writing my own nntp/email client (actually, i'm writing this post with it).

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: Thanks for the very comprehensive response! I think most of my doubts are cleared now. You're right though that I'm probably worrying too much about GC with my current use case. i can tell you that i'm doing things like, for example, ZX Spectrum emulator and hobbyst

Re: Hello, folks! Newbie to D, have some questions!

2017-02-19 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: I can't help here because I am using D for a long time, so I do not remember how I have learned it. Hahaha! Yes, thanks for the honesty. It does make sense because once you've been working in some field for some time, it does make it harder to explain how exactly you reached

Re: Hello, folks! Newbie to D, have some questions!

2017-02-19 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: a). So the GC is part of the runtime even if we specify @nogc yes. GC is basically just a set of functions and some supporting data structures, it is compiled in druntime. @nogc doesn't turn it off, if says that compiler must ensure that *your* *code* doesn't allocate, at

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
"H. S. Teoh via Digitalmars-d-learn" wrote: On Mon, Feb 20, 2017 at 05:39:30PM +0000, ketmar via Digitalmars-d-learn wrote: foreach (auto n; arr) oops. good job, auto! Haha... in this case you want to actually just drop `auto` completely. :-D But yeah, there are some funny incon

Re: RAII

2017-02-23 Thread ketmar via Digitalmars-d-learn
Arun Chandrasekaran wrote: On Thursday, 23 February 2017 at 09:57:09 UTC, ketmar wrote: Thanks for your help. NRVO looks interesting. However this may not be RAII after all. Or may be too much of C++ has spoiled me. I am not familiar enough with D to appreciate/question the language design

Re: Pointers vs functional or array semantics

2017-02-25 Thread ketmar via Digitalmars-d-learn
data pulverizer wrote: I have noticed that some numerical packages written in D use pointer semantics heavily (not referring to packages that link to C libraries). I am in the process of writing code for a numerical computing library and would like to know whether there times when addressing

Re: RAII

2017-02-23 Thread ketmar via Digitalmars-d-learn
Arun Chandrasekaran wrote: I'm trying to write an RAII wrapper on Linux. I understand struct in D doesn't have default constructor (for .init reasons). I don't want to use `scope`. Is there an elegant way to achieve this in D? why not static method or free function that returns struct? due

Re: C++-style mutable members

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:21:34 UTC, Nordlöw wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different meaning of `const` in D and C++.

Re: C++-style mutable members

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:50:34 UTC, Nordlöw wrote: On Tuesday, 17 January 2017 at 20:47:35 UTC, ketmar wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different meaning of

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:37:46 UTC, Samwise wrote: extern int getReturnCode() { return 4; } still does not compile using the command from above. I may very well be misunderstanding you though. yep. *both* prototype and real declaration should be `extern(C)`. `(C)` part is

Re: Thread will get garbage collected?

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 08:58:33 UTC, Arun Chandrasekaran wrote: Interesting. Why doesn't the thread get GC'd in this case even without any reference still active? basically 'cause there is no reliable way to correctly "abort" a thread. nobody knows what is really going on inside it,

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 04:06:23 UTC, Samwise wrote: I have both the header in hello.d and the actual function in getReturnCode.d as extern, and it still fails with the same error. nope. it works.

Re: Unresolved Symbols in a nanovg Library

2016-10-26 Thread ketmar via Digitalmars-d-learn
On Thursday, 27 October 2016 at 02:12:34 UTC, Jason C. Wells wrote: I have no idea where this ModuleInfoZ thing is coming from. as Adam said, it means that it imports some module, and you didn't passed it to dmd. in this case, it is iv.nanovg.oui package (this is Blender-like GUI controls --

Re: Unresolved Symbols in a nanovg Library

2016-10-26 Thread ketmar via Digitalmars-d-learn
On Thursday, 27 October 2016 at 01:48:54 UTC, Jason C. Wells wrote: I'm not sure I fully understand name mangling, but it looks like nanovg wants to use iv\stb\ttf.d from it's own source tree. But Ketmar said "p.s. you will also need stb_ttf port, arsd repo has it under the name "ttf.d"." So

Re: Module Name Resolution

2016-10-25 Thread ketmar via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 05:27:53 UTC, Jason C. Wells wrote: Hence the repeated advice to supply all the filenames on the command line. this is basically 'cause dmd doesn't automatically compile and link imported modules. it you won't specify module in dmd command line, dmd will only

Re: Module Name Resolution

2016-10-25 Thread ketmar via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 04:51:23 UTC, Jason C. Wells wrote: I am reading through Ketmar's iv.d/nanovg/package.d: module iv.nanovg; public import iv.nanovg.nanovg; This looks like three levels of hierarchy, but is it? it maps to "iv/nanovg/nanovg.d" according to dmd map rules. i

Re: Question on syntax

2016-11-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 9 November 2016 at 06:28:31 UTC, Jim wrote: What does it mean when a variable name starts with a '.' `.a` --> `::a`.

Re: is operator and SortedRange

2016-11-11 Thread ketmar via Digitalmars-d-learn
On Friday, 11 November 2016 at 11:49:25 UTC, RazvanN wrote: I am a bit confused about how the is operator works. I have a function which receives an InputRange and a predicate. Now I need to be able to test if the InputRange is actually a SortedRange. I don't care about how the datatypes

Re: Render SVG To Display And Update Periodically

2016-10-19 Thread ketmar via Digitalmars-d-learn
On Wednesday, 19 October 2016 at 03:27:10 UTC, Basile B. wrote: https://github.com/Pctg-x8/nanovg-d, I even think it's been announced here last year. this is wrapper. my thing is complete port.

Re: Render SVG To Display And Update Periodically

2016-10-19 Thread ketmar via Digitalmars-d-learn
On Tuesday, 18 October 2016 at 21:00:12 UTC, Karabuta wrote: This thing really needs a GitHub repo never.

Re: Render SVG To Display And Update Periodically

2016-10-22 Thread ketmar via Digitalmars-d-learn
On Saturday, 22 October 2016 at 03:59:16 UTC, Jason C. Wells wrote: nanovg_demo>dmd example.d iv\arsd\color.d iv\arsd\simpledisplay.d iv\perf.d iv\perf.d(41): Error: module iv.nanovg.nanovg from file iv\nanovg.d must be imported with 'import iv.nanovg.nanovg;' demo.d(6): Error:

Re: Render SVG To Display And Update Periodically

2016-10-17 Thread ketmar via Digitalmars-d-learn
On Monday, 17 October 2016 at 02:07:47 UTC, rikki cattermole wrote: You're going to need to find an svg rasterizer in some form or another. I don't think we have one in D and certainly not a complete one. 'cmon, you know that i have a working port of NanoSVG! and it works on top of NanoVG,

Re: Render SVG To Display And Update Periodically

2016-10-17 Thread ketmar via Digitalmars-d-learn
On Monday, 17 October 2016 at 07:05:24 UTC, ketmar wrote: On Monday, 17 October 2016 at 02:07:47 UTC, rikki cattermole wrote: You're going to need to find an svg rasterizer in some form or another. I don't think we have one in D and certainly not a complete one. 'cmon, you know that i have a

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:00:58 UTC, Steven Schveighoffer wrote: I can't see why you need to deal with the glue layer at all -- just tell the glue layer that it's a list of strings and not dstrings ;) 'cause that is how s2ir.d is done in dmd. ;-) it actually sorts *objects*, and

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:19:04 UTC, Tofu Ninja wrote: You still can't replicate a function with this. you can, by using std.traits and string mixins.

Re: A simplification of the RvalueRef idiom

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:35:39 UTC, TheGag96 wrote: The thing that gets me more is "return" as a function attribute. I see it under "MemberFunctionAttribute" in the grammar but I can't find an explanation for its use anywhere... YOU ARE NOT SUPPOSED TO KNOW THIS. DON'T LIVE YOUR

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int) seems like a bug. you are unable to alias it, `ref` will be erased on aliasing. the only way to retain it is to have a tuple with it. that trick aliases *function* *argument* *tuple*,

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref int" as its only member? Since when is ref int a type? it is "type with modifier", like "const int" or "immutable int".

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:28:57 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 22:19:28 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref int" as its only member? Since when is ref int a type? it

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:04:51 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 23:21:53 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int) seems like a bug. you are unable to alias it, `ref` will be

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:51:01 UTC, Tofu Ninja wrote: Even with std.traits, you can't know which arguments are variadic. sure, you can. see http://dpldocs.info/experimental-docs/std.traits.variadicFunctionStyle.html that will return variadic style. and the only argument that can

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 02:52:05 UTC, Tofu Ninja wrote: On Thursday, 24 November 2016 at 02:11:21 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:51:01 UTC, Tofu Ninja wrote: Even with std.traits, you can't know which arguments are variadic. sure, you can. see

Re: the best language I have ever met(?)

2016-11-25 Thread ketmar via Digitalmars-d-learn
On Friday, 25 November 2016 at 14:27:39 UTC, Igor Shirkalin wrote: On Wednesday, 23 November 2016 at 18:58:55 UTC, ketmar wrote: We can define static array without counting the elements as following: enum array_ = [1u,2,3,4]; uint[array_.length] static_array = array_; there are

Re: the best language I have ever met(?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 18:54:35 UTC, Igor Shirkalin wrote: On Tuesday, 22 November 2016 at 00:08:05 UTC, ketmar wrote: On Monday, 21 November 2016 at 23:49:27 UTC, burjui wrote: Though I would argue that it's better to use '_' instead of '$' to denote deduced fixed size, it seems

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 20:49:01 UTC, Chris wrote: Actually, I came across a compiler message that gave me something like \x19\x20 which I found odd. This sure needs fixing. After all, it's quite a basic feature. So it's back to the old `if` again (for now). yeah, until this is

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
quickfix: diff --git a/src/rt/switch_.d b/src/rt/switch_.d index ec124e3..83572fe 100644 --- a/src/rt/switch_.d +++ b/src/rt/switch_.d @@ -27,6 +27,32 @@ private import core.stdc.string; extern (C): +import core.stdc.wchar_ : wchar_t, wmemcmp; + + +static if (wchar_t.sizeof == wchar.sizeof)

Re: the best language I have ever met(?)

2016-11-21 Thread ketmar via Digitalmars-d-learn
On Monday, 21 November 2016 at 12:44:47 UTC, Jonathan M Davis wrote: (it might have even had a PR which was rejected), and presumably, Ketmar added it to his own compiler, because he liked the feature. exactly. it is the old patch from Kenji. the patch even survived C++ -> D transition, 'cause

Re: the best language I have ever met(?)

2016-11-21 Thread ketmar via Digitalmars-d-learn
On Monday, 21 November 2016 at 23:49:27 UTC, burjui wrote: Though I would argue that it's better to use '_' instead of '$' to denote deduced fixed size, it seems more obvious to me: int[_] array = [ 1, 2, 3 ]; alas, `_` is valid identifier, so `enum _ = 42; int[_] a;` is perfectly valid.

Re: Switch ignores case (?)

2016-11-24 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 09:56:25 UTC, Chris wrote: Great job, ketmar! I'm only surprised that this bug wasn't discovered earlier, I mean it goes back to (at least) dmd 2.040. thanks. tbh, i am surprised myself -- it is completely fubared, but nobody noticed. maybe that says something

Re: mixin templates as ailas paramters

2016-11-24 Thread ketmar via Digitalmars-d-learn
On Friday, 25 November 2016 at 00:43:25 UTC, Nicholas Wilson wrote: works like a charm: mixin template Foo(T) { int z = 42; } auto Bar(alias a) () { mixin a!int; return z; } void main () { writeln(Bar!Foo); }

Re: Switch ignores case (?)

2016-11-24 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 11:40:24 UTC, Antonio Corbi wrote: Could it be possible to ping M. Nowak to include the fix for this bug (due to its importance) in the final 2.072.1 release? there is no real fix yet. what i provided is a quick hack, not tested on anything except GNU/Linux,

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 21:31:08 UTC, Steven Schveighoffer wrote: I think it makes the most sense to remove the memcmp, and do binary search based on actual char values. yeah. there is wmemcmp, which can be used to speed up one of the cases ('cause wchar_t has different size on

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 21:40:52 UTC, Steven Schveighoffer wrote: So the better way is to sort based on byte array, and just use memcmp for everything. i am not completely sure that this is really better. sorting and generating tables is done in glue layer, which can be different

Re: the best language I have ever met(?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 19:15:52 UTC, Jonathan M Davis wrote: It's nice, but it's non-standard. So, it seems to me that using it is just going to lead to problems like you ran into in this thread where you posted an example that wasn't valid D, and it'll make you that much more

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 19:07:49 UTC, Chris wrote: It has something to do with the smart quote, e.g.: it is wrong binary search in `_d_switch_string()`. strings for switch are lexically sorted, and compiler calls `_d_switch_string()` to select one. the thing is that comparison in

Re: the best language I have ever met(?)

2016-11-18 Thread ketmar via Digitalmars-d-learn
On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote: After 2 hours of brain breaking (as D newbie) I have come to: uint_array.map!(v=>"%x".format(v)).join(", ") Why 2 hours? Because I have started with 'joiner' function and aftewords found out the 'join'. To my mind there is

Re: the best language I have ever met(?)

2016-11-18 Thread ketmar via Digitalmars-d-learn
On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote: Please don't post non-d. it slipped accidentally, sorry. ;-) for OP: `uint[2] a = [42, 69];` is the correct syntax.

Re: the best language I have ever met(?)

2016-11-19 Thread ketmar via Digitalmars-d-learn
On Saturday, 19 November 2016 at 17:12:13 UTC, Igor Shirkalin wrote: string s = "%(%s, %)".format(a); writefln(s); } Accepted. Is it really needed to call 'writefln'? I mean 'f'. no. it's a leftover from the code without format. it originally was `writefln("%(%s, %)", a);`, but i wanted

Re: Using opApply and Attributes

2016-11-20 Thread ketmar via Digitalmars-d-learn
On Sunday, 20 November 2016 at 16:36:18 UTC, Q. Schroll wrote: How can I have relative-@attrib functions without unnecessary manual overloading? import std.traits; auto f1(DG) (DG dg) if (isCallable!DG && Parameters!DG.length == 1 && is(Parameters!DG[0] == int)) { // check other things here

Re: the best language I have ever met(?)

2016-11-21 Thread ketmar via Digitalmars-d-learn
On Monday, 21 November 2016 at 12:42:34 UTC, ZombineDev wrote: That was a proposal for D that was rejected in the last moment by Andrei. My guess is that ketmar's modified dmd has that feature implemented. exactly. it is handy feature, so i used to it. and it slept into code (i usually test

Re: Making floating point deterministic cross diffrent platforms/hardware

2016-11-20 Thread ketmar via Digitalmars-d-learn
On Sunday, 20 November 2016 at 21:31:09 UTC, Guillaume Piolat wrote: I think you can roughly have that with ldc, always using SSE and the same rounding-mode. ARM. oops.

Re: Making floating point deterministic cross diffrent platforms/hardware

2016-11-20 Thread ketmar via Digitalmars-d-learn
write your own software fp library. this is the only way to cover all your broad cases.

Re: Illegal behaviour or GDC bug?

2016-10-13 Thread ketmar via Digitalmars-d-learn
sadly, gdc has way older frontend version than ldc (and dmd, of course). gdc is like 2.067, and ldc/dmd is 2.072. that this was fixed in later versions, but gdc is not updated yet.

Re: ReturnType and Parameters of Templated function/method

2016-10-13 Thread ketmar via Digitalmars-d-learn
On Thursday, 13 October 2016 at 20:52:09 UTC, Patric Dexheimer wrote: So for now my idea is to brute force the numbers of arguments with 'compiles' trait or trying to get the sourcecode somehow. depending on source code form (even if you can get it) is highly error-prone. consider it UB.

Re: Illegal behaviour or GDC bug?

2016-10-13 Thread ketmar via Digitalmars-d-learn
On Thursday, 13 October 2016 at 20:22:51 UTC, Peter Campbell wrote: OK that's cool, I'll just avoid GDC for now. Is it generally a good approach to assume if something compiles in DMD then it's correct and just hope that GDC/LDC pick up the latest version at some point? mostly yes. btw, ldc

Re: Variables with scoped destruction in closures

2016-10-16 Thread ketmar via Digitalmars-d-learn
On Saturday, 15 October 2016 at 05:41:05 UTC, Walter Bright wrote: The problem is the closure is generated when it is expected that the delegate will survive past the end of the scope (it's the whole point of a closure). But with a destructor that runs at the end of the scope, it cannot

Re: Building DMD with DMD or LDC

2016-10-16 Thread ketmar via Digitalmars-d-learn
On Saturday, 15 October 2016 at 07:39:31 UTC, ketmar wrote: p.s. this is all about GNU/Linux on x86 arch. for other OS/arch it may be completely different.

Re: Building DMD with DMD or LDC

2016-10-16 Thread ketmar via Digitalmars-d-learn
On Friday, 14 October 2016 at 15:13:58 UTC, Jonathan M Davis wrote: On Thursday, October 13, 2016 19:07:44 Nordlöw via Digitalmars-d-learn wrote: Is there a large speed difference in compilation time depending on whether the DMD used is built using DMD or LDC? I would be shocked if there

Re: Variables with scoped destruction in closures

2016-10-16 Thread ketmar via Digitalmars-d-learn
On Saturday, 15 October 2016 at 07:55:30 UTC, ketmar wrote: p.s. compiler doesn't complain each time, only in some circumstances. i don't remember the exact code now, but some of it has nothing to do with closures at all -- no std.algo, no templates with lambda args, etc.

Re: [Semi-OT] I don't want to leave this language!

2016-12-08 Thread ketmar via Digitalmars-d-learn
On Thursday, 8 December 2016 at 10:49:40 UTC, Chris wrote: The "hard way" (no runtime/Phobos/GC) should not be the default and I hope that nobody is seriously suggesting this. It should be available in case anyone needs it. I dare doubt, however, that C/C++ programmers will take to D like

Re: Alias variable from another class

2016-12-14 Thread ketmar via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 19:13:24 UTC, Begah wrote: Any ideas? you can't.

Re: [Semi-OT] I don't want to leave this language!

2016-12-06 Thread ketmar via Digitalmars-d-learn
On Wednesday, 7 December 2016 at 02:38:50 UTC, bpr wrote: It's a counterfactual at this point, but I would guess that if D had left out the GC in 2010 when D2 came out it would have been ahead of C++ in many ways and perhaps would have been able to peel off more C++ programmers c++

Re: [Semi-OT] I don't want to leave this language!

2016-12-07 Thread ketmar via Digitalmars-d-learn
On Wednesday, 7 December 2016 at 09:45:39 UTC, Andrey wrote: I think, a good way to step up for Dlang is to be C++ like Ada variant, with possibility to work without GC. you do know that you *can* use D without GC even now, do you?

Re: Cryptic C function pointer for conversion

2016-12-17 Thread ketmar via Digitalmars-d-learn
On Saturday, 17 December 2016 at 13:39:27 UTC, data pulverizer wrote: that is what it means, in D: //void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); struct sqlite3_vfs {} extern(C) { alias RetRes = void function (); alias DeclType = RetRes function (sqlite3_vfs *a,void

Re: Cryptic C function pointer for conversion

2016-12-17 Thread ketmar via Digitalmars-d-learn
p.s.: that means that i didn't really *decoded* that declaration, just brute-forced someting that c++ compiler happily accepts. so take it with a grain of salt. ;-)

Re: Cryptic C function pointer for conversion

2016-12-17 Thread ketmar via Digitalmars-d-learn
On Saturday, 17 December 2016 at 15:15:26 UTC, data pulverizer wrote: Does this mean that you can translate C code to D natively? I am currently only aware of the dstep package. with my head and bare hands. well, armed with some regular expressions. did you seen some of my "port"

Re: Calling arbitrary functions at runtime?

2016-12-11 Thread ketmar via Digitalmars-d-learn
import std.traits; import std.stdio; alias FDg = void delegate (string args); FDg[string] cmdlist; void register(DG) (string name, DG dg) if (isCallable!DG) { cmdlist[name] = delegate (string args) { import std.array : split; import std.conv : to; alias Args = Parameters!DG;

Re: @property get/set or public varaible?

2016-12-04 Thread ketmar via Digitalmars-d-learn
On Sunday, 4 December 2016 at 15:30:22 UTC, vladdeSV wrote: Are there any other reasons to use get/setters? basically, no. as you can omit parentheses in D, converting to getter/setter later should be seamless. the only reason to have getter/setter in your case is a situation where you may

Re: Imports incorrectly part of "allMembers" trait output?

2017-01-03 Thread ketmar via Digitalmars-d-learn
given the way your code is written, "std" namespace *is* a member. it will be very useful when we'll fix other bugs and recursive `allMembers` scan will become possible. so while it came from namespaces implementation, i don't see this as a bug. it is little annoying, yes, 'cause you *have* to

Re: compile-time test against dmd/phobos version number

2017-01-06 Thread ketmar via Digitalmars-d-learn
On Saturday, 7 January 2017 at 02:30:53 UTC, Jon Degenhardt wrote: Is there a way to make a compile time check against the dmd/phobos version number? Functionally, what I'd like to achieve would be equivalent to: version(dmdVersion >= 2.070.1) { } else {

Re: Imports incorrectly part of "allMembers" trait output?

2017-01-03 Thread ketmar via Digitalmars-d-learn
On Tuesday, 3 January 2017 at 06:23:01 UTC, bauss wrote: It seems to be a bug that it takes std as there's no std as a part of object, not even as an import. there is. think of it as "ephemeral namespace entity" (kind of alias to "name bin" that compiler created, the entity that exists, just

Re: Iterate module membres

2017-01-07 Thread ketmar via Digitalmars-d-learn
On Saturday, 7 January 2017 at 13:45:53 UTC, crimaniak wrote: Ok, I found it: https://issues.dlang.org/show_bug.cgi?id=16044 yep. sorry, my search-fu is completely broken, so i didn't provide you with the number.

Re: Iterate module membres

2017-01-07 Thread ketmar via Digitalmars-d-learn
On Saturday, 7 January 2017 at 12:11:20 UTC, crimaniak wrote: Is this a bug or documentation problem? well, it's hard to say. package.d is one of the cases where you *have* to provide explicit module definition. ;-) 'cause implicit one creates module with name `package`, which is teh

Re: Iterate module membres

2017-01-07 Thread ketmar via Digitalmars-d-learn
p.s.: otherwise, it *should* work with explicit module declaration. but then, we have some well-known bugs with cross-module introspection, and some heisenbugs with package introspection.

Re: Iterate module membres

2017-01-07 Thread ketmar via Digitalmars-d-learn
On Saturday, 7 January 2017 at 09:46:54 UTC, crimaniak wrote: Hi! I need to iterate module members and find specific classes (and make tuple). class foo{}; pragma (msg, __traits(allMembers,mixin(__MODULE__))); gives me empty tuple. works like a charm both in 2.071 and in git HEAD.

Re: Iterate module membres

2017-01-07 Thread ketmar via Digitalmars-d-learn
On Saturday, 7 January 2017 at 10:27:51 UTC, Nicholas Wilson wrote: Do you require a module statement per chance? it doesn't matter. if there is no explicit module declaration, compiler will insert implicit one. from the code PoV, there is no difference at all.

Re: Pointer to private structure

2016-12-18 Thread ketmar via Digitalmars-d-learn
i bet that just trying this with D compiler will take less time than writing forum post.

Re: Accessing a function within an object's superclass from the outside

2017-01-14 Thread ketmar via Digitalmars-d-learn
On Saturday, 14 January 2017 at 22:38:15 UTC, David Zhang wrote: On Saturday, 14 January 2017 at 22:17:23 UTC, ketmar wrote: class ClassB: ClassA { alias fun = super.fun; override void fun(uint a) {} } I tried that, but it seems to think I mean to override super.fun(uint) instead of

Re: union.sizeof

2017-03-26 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: On Sunday, 26 March 2017 at 06:45:13 UTC, ketmar wrote: yes. you have a typo in second `writefln`: S1 instead of S2. ;-) thank you. another question, related to my first post: why size of S2.b1 and S2.b2 still 3, not 4? am i right: then align applied to members, compiler

Re: union.sizeof

2017-03-26 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote: most of the time either location or padding will work the same. hmm.. you ruined my expirence.. i made another experiment. whould you please explain me S2 size 6? thank you for you time. yes. you have a typo in second

Re: union.sizeof

2017-03-25 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: //DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio: writefln; writefln("Union1.sizeof=%d", Union1.sizeof);

Re: union.sizeof

2017-03-25 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: Thank you ag0aep6g and ketmar!! I will use additional outside align. I want packing inside, you are right. But i check result size with assert() and failed. But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X)

Re: real simple manifest constant question probably regret asking...

2017-03-15 Thread ketmar via Digitalmars-d-learn
WhatMeForget wrote: One of my D books says: "an enum declared without any braces is called a manifest constant." The example shows, enum string author = "Mike Parker"; Is this equivalent to const string author = "Mike Parker"; or immutable string author = "Mike Parker"; I guess what I'm

Re: Function Template Overloading

2017-03-14 Thread ketmar via Digitalmars-d-learn
Q. Schroll wrote: void test(T)(T* arg); void test(T)(ref T arg); Let p be any pointer. Why is test(p) not an ambiguity error? Why is the second overload chosen? 'cause `ref T` is more generic than `T*`. think of it as "greedy matching": compiler first tries to match `int*`, and if that

Re: Playing arround with mixin - alias?

2017-04-21 Thread ketmar via Digitalmars-d-learn
Martin Tschierschke wrote: Is it possible to define an alias for something like mixin(import("local_function_file.d")); to write only use_local_function; which will be translated to: mixin(import("local_function_file.d")); (this additionally needs the file local_function_file.d in

Re: Playing arround with mixin - alias?

2017-04-21 Thread ketmar via Digitalmars-d-learn
biozic wrote: On Friday, 21 April 2017 at 09:42:33 UTC, ketmar wrote: Martin Tschierschke wrote: Is it possible to define an alias for something like mixin(import("local_function_file.d")); to write only use_local_function; which will be translated to:

Re: Playing arround with mixin - alias?

2017-04-21 Thread ketmar via Digitalmars-d-learn
Martin Tschierschke wrote: i doubt so. So my "solution" on how to get a short cut for using: writeln(mixin(interp!"${name} you are app. ${age*365} days old")); .. NEVER. EVER. USE. THE. FOLOWING. IN. YOUR. CODE. NEVER!!! import std.stdio; mixin template usesexpand() { import

Re: Always std.utf.validate, or rely on exceptions?

2017-03-02 Thread ketmar via Digitalmars-d-learn
SimonN wrote: Should I always validate text from files manually with std.utf.validate? Or should I memorize which functions throw, then validate manually whenever I call the non-throwing UTF functions? What is the pattern behind what throws and what asserts false? i'd say: "ALWAYS validate

Re: C interface provides a pointer and a length... wrap without copying?

2017-03-11 Thread ketmar via Digitalmars-d-learn
cy wrote: So a lovely C library does its own opaque allocation, and provides access to the malloc'd memory, and that memory's length. Instead of copying the results into garbage collected memory (which would probably be smart) I was thinking about creating a structure like: struct

Re: C interface provides a pointer and a length... wrap without copying?

2017-03-11 Thread ketmar via Digitalmars-d-learn
cy wrote: On Saturday, 11 March 2017 at 23:43:54 UTC, Nicholas Wilson wrote: A string *is* a pointer length pair, an immutable(char)[]. Yes, but surely there's some silly requirement, like that the pointer must only ever point to garbage collected memory, or something? why should it? a

Re: I think is a bug?

2017-03-11 Thread ketmar via Digitalmars-d-learn
Random D user wrote: How come string* suddenly has a .length property? due to automatic pointer dereferencing that `.` does. no, not a bug.

  1   2   3   4   5   6   7   8   9   10   >