Re: undefined symbol: _D3std7variant...

2019-10-23 Thread baz via Digitalmars-d-learn
On Tuesday, 22 October 2019 at 13:07:54 UTC, Andrey wrote: On Tuesday, 22 October 2019 at 12:57:45 UTC, Daniel Kozak wrote: Have you try to clean all caches? Try to remove .dub folder I removed .dub folder but this error appears again. Try the "-allinst" option. It's possibly a bug with spec

Re: crash when using &this in struct constructor

2018-07-18 Thread baz via Digitalmars-d-learn
On Wednesday, 18 July 2018 at 11:35:40 UTC, baz wrote: On Wednesday, 18 July 2018 at 11:27:33 UTC, baz@dlang-community wrote: On Monday, 16 July 2018 at 22:21:12 UTC, H. S. Teoh wrote: On Mon, Jul 16, 2018 at 10:08:34PM +, Eric via Digitalmars-d-learn wrote: [...] It's not illega

Re: crash when using &this in struct constructor

2018-07-18 Thread baz via Digitalmars-d-learn
On Wednesday, 18 July 2018 at 11:27:33 UTC, baz@dlang-community wrote: On Monday, 16 July 2018 at 22:21:12 UTC, H. S. Teoh wrote: On Mon, Jul 16, 2018 at 10:08:34PM +, Eric via Digitalmars-d-learn wrote: [...] It's not illegal per se, but a very, very bad idea in general, because

Re: crash when using &this in struct constructor

2018-07-18 Thread baz@dlang-community via Digitalmars-d-learn
On Monday, 16 July 2018 at 22:21:12 UTC, H. S. Teoh wrote: On Mon, Jul 16, 2018 at 10:08:34PM +, Eric via Digitalmars-d-learn wrote: [...] It's not illegal per se, but a very, very bad idea in general, because in D, structs are expected to be int-like POD values that can be freely copied

Re: HMAC and toHexString

2018-07-18 Thread baz@dlang-community via Digitalmars-d-learn
On Wednesday, 18 July 2018 at 11:22:36 UTC, Nicholas Wilson wrote: On Wednesday, 18 July 2018 at 05:54:48 UTC, Nicholas Wilson wrote: [...] Ahh, the joys of memory corruption. You've reached https://issues.dlang.org/show_bug.cgi?id=16519 maybe ?

Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 11:08:00 UTC, Rikki Cattermole wrote: On 21/07/2015 10:36 p.m., Baz wrote: [...] I'll summarize what my friend is saying. netsh is potentially going away. Don't use it if you can. Since you are using a localized system it, it may be causing issu

Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 10:41:54 UTC, Kagamin wrote: try this: import std.process, std.stdio; import core.thread; import std.random; void main(string[] args) { string on = "netsh interface set interface \"Connexion au réseau local\" Enable"; string off = "netsh interface set interf

Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 10:28:27 UTC, Rikki Cattermole wrote: On 21/07/2015 10:14 p.m., Baz wrote: --- import std.process; import core.thread; import std.random; void main(string[] args) { string on = "netsh interface set interface \"Connexion au réseau local\" Enabl

Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn
--- import std.process; import core.thread; import std.random; void main(string[] args) { string on = "netsh interface set interface \"Connexion au réseau local\" Enable"; string off = "netsh interface set interface \"Connexion au réseau local\" Disable"; while(true) {

Re: Virtual value types during compile-time for static type safety, static optimizations and function overloading.

2015-07-17 Thread Baz via Digitalmars-d-learn
On Friday, 17 July 2015 at 21:20:41 UTC, Tamas wrote: Although this code is fully operational, presents nice api and compile-time optimizations, the extra Struct wrapper is not without runtime penalty. Is there a solution that results the same static optimizations, but has no runtime penalty,

Re: Linked variables

2015-07-14 Thread Baz via Digitalmars-d-learn
On Monday, 13 July 2015 at 22:07:11 UTC, Tanel Tagaväli wrote: Does the standard library have a way to create a forward link between two variables of the same type? One variable is the source and the other is the sink. When the source variable is changed, the sink variable is too. Changing the s

Re: Manually allocate delegate?

2015-07-12 Thread Baz via Digitalmars-d-learn
On Sunday, 12 July 2015 at 10:39:44 UTC, Tofu Ninja wrote: On Sunday, 12 July 2015 at 10:19:02 UTC, Baz wrote: [...] That is not manually allocating a delegate context, and & in that instance does not even allocate. For delegates to class methods, the context is just the "this&qu

Re: Manually allocate delegate?

2015-07-12 Thread Baz via Digitalmars-d-learn
On Sunday, 12 July 2015 at 09:03:25 UTC, Tofu Ninja wrote: On Sunday, 12 July 2015 at 08:47:37 UTC, ketmar wrote: On Sun, 12 Jul 2015 08:38:00 +, Tofu Ninja wrote: Is it even possible? what do you mean? Sorry, thought the title was enough. The context for a delegate(assuming not a met

Re: Replacement of std.stream

2015-06-28 Thread Baz via Digitalmars-d-learn
On Sunday, 28 June 2015 at 05:04:48 UTC, DlangLearner wrote: I will convert a Java program into D. The original Java code is based on the class RandomeAccessFile which essentially defines a set of methods for read/write Int/Long/Float/String etc. The module std.stream seems to be a good fit for

Re: fast way to insert element at index 0

2015-06-23 Thread Baz via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 13:29:41 UTC, Steven Schveighoffer wrote: On 6/23/15 8:12 AM, Baz wrote: On Tuesday, 23 June 2015 at 11:22:31 UTC, Steven Schveighoffer wrote: [...] according to the C library, memmove handle overlapps, you mismatch with memcpy which does not. The above is

Re: fast way to insert element at index 0

2015-06-23 Thread Baz via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 11:22:31 UTC, Steven Schveighoffer wrote: On 6/23/15 1:51 AM, jkpl wrote: On Tuesday, 23 June 2015 at 05:16:23 UTC, Assembly wrote: [...] * Option 1/ if most of the time you have to insert at the beginning, then start reading from the end and append to the end, s

Re: Program exited with code -11

2015-06-23 Thread Baz via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 07:25:05 UTC, Baz wrote: in dmd you have to pass - the .lib/.a files a source I meant "as source", actually. you pass the .lib or .a file without switch as if it's a main source.

Re: Program exited with code -11

2015-06-23 Thread Baz via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote: On Tuesday, 23 June 2015 at 03:31:37 UTC, weaselcat wrote: On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins wrote: Thanks, Adam. I'm coming from OCaml and haven't seen a seg fault in years. Didn't recognize it. :D Hope

Re: Return types of the methods of a struct

2015-06-19 Thread Baz via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:52:54 UTC, Quentin Ladeveze wrote: On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer wrote: Does this work for you, or is there a further expectation? auto asTuple() { return Tuple!(int, "a", ...)(a, b, stringValue);} -Steve In fact, I was trying

Re: Return types of the methods of a struct

2015-06-19 Thread Baz via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:40:01 UTC, Baz wrote: On Friday, 19 June 2015 at 13:27:15 UTC, Quentin Ladeveze wrote: On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer wrote: [...] Thank you :) Here is th corrected version : Hi, I have a struct with some methods int it, let&#

Re: Return types of the methods of a struct

2015-06-19 Thread Baz via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:27:15 UTC, Quentin Ladeveze wrote: On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer wrote: On 6/19/15 9:13 AM, Quentin Ladeveze wrote: [...] You can't. The forum is backed by a newsgroup, just post the full corrected version :) -Steve Thank you

Re: Casting MapResult

2015-06-15 Thread Baz via Digitalmars-d-learn
On Monday, 15 June 2015 at 20:10:30 UTC, jmh530 wrote: I suppose I would want whichever has the best performance. Without testing, I'm not sure which one would be better. Thoughts? I had been fighting with the map results because I didn't realize there was an easy way to get just the array.

Re: Casting MapResult

2015-06-15 Thread Baz via Digitalmars-d-learn
On Monday, 15 June 2015 at 19:22:31 UTC, jmh530 wrote: On Monday, 15 June 2015 at 19:04:32 UTC, Baz wrote: In addition to the other answers you can use std.algorithm.iteration.each(): --- float[] _exp(float[] x) { auto result = x.dup; result.each!(a => exp(a)); return res

Re: Casting MapResult

2015-06-15 Thread Baz via Digitalmars-d-learn
On Monday, 15 June 2015 at 19:30:08 UTC, Baz wrote: On Monday, 15 June 2015 at 19:22:31 UTC, jmh530 wrote: On Monday, 15 June 2015 at 19:04:32 UTC, Baz wrote: In addition to the other answers you can use std.algorithm.iteration.each(): --- float[] _exp(float[] x) { auto result = x.dup

Re: Casting MapResult

2015-06-15 Thread Baz via Digitalmars-d-learn
On Monday, 15 June 2015 at 15:10:24 UTC, jmh530 wrote: I wrote a simple function to apply map to a float dynamic array auto exp(float[] x) { auto y = x.map!(a => exp(a)); return y; } However, the type of the result is MapResult!(__lambda2, float[]). It seems like some of the th

Re: Extract template parameter at runtime?

2015-06-15 Thread Baz via Digitalmars-d-learn
On Monday, 15 June 2015 at 18:10:34 UTC, Yuxuan Shui wrote: Can is() operate on TypeInfo? yes, you can compare instance of TypeInfo using is or '==' too, using typeid which is returns at run-time the TypeInfo of the argument: --- void main() { assert(typeid(2) == typeid(1)); assert(t

Re: Process a TypeTuple

2015-06-14 Thread Baz via Digitalmars-d-learn
On Monday, 15 June 2015 at 03:53:35 UTC, Yuxuan Shui wrote: Is it possible to apply some operation on every member of a TypeTuple, then get the result back? Say I have a TypeTuple of array types, and I want a TypeTuple of their element types, how could I do that? You can do that with std.typ

Re: dmd and string imports on Windows

2015-06-10 Thread Baz via Digitalmars-d-learn
On Wednesday, 10 June 2015 at 19:59:17 UTC, Atila Neves wrote: On Linux: foo.d: import std.stdio; void main() { writeln(import("dir/bar.txt")); } dmd -J. foo.d # ok On Windows: Error: file "dir/bar.txt" cannot be found or not in a path specified with -J I tried the obvious buildPath("dir",

Re: ImplicitConversionTargets opposite

2015-05-22 Thread Baz via Digitalmars-d-learn
the line warping on this forum deserve a big slap in the face...

Re: ImplicitConversionTargets opposite

2015-05-22 Thread Baz via Digitalmars-d-learn
On Thursday, 21 May 2015 at 21:49:55 UTC, Freddy wrote: std.traits has ImplicitConversionTargets. Is there any template that returns the types that can implicty convert to T? You can write something like this: --- import std.stdio; import std.traits; import std.typetuple; void main(string[]

Re: deserialization: creating a class instance without calling constructor

2015-05-21 Thread Baz via Digitalmars-d-learn
On Thursday, 21 May 2015 at 09:06:59 UTC, Timothee Cour wrote: Can I create an instance of A without calling a constructor? (see below) Use case: for generic deserialiaztion, when the deserialization library encounters a class without default constructor for example (it knows what the fields sh

control flow with a functional template ?

2015-05-18 Thread Baz via Digitalmars-d-learn
who's never had to do this: --- if (comparison) { statement; break; } --- ans then thought it's a pity to open/closes the braces just for a simple statement. Would it be possible to have a template to simplify this to: --- if (comparison) Break!(expression); --- or even at the l

Re: mscoff x86 invalid pointers

2015-05-10 Thread Baz via Digitalmars-d-learn
On Sunday, 10 May 2015 at 12:20:39 UTC, Etienne Cimon wrote: On 2015-05-10 03:54, Baz wrote: On Sunday, 10 May 2015 at 04:16:45 UTC, Etienne Cimon wrote: On 2015-05-09 05:44, Baz wrote: On Saturday, 9 May 2015 at 06:21:11 UTC, extrawurst wrote: On Saturday, 9 May 2015 at 00:16:28 UTC

Re: mscoff x86 invalid pointers

2015-05-10 Thread Baz via Digitalmars-d-learn
On Sunday, 10 May 2015 at 04:16:45 UTC, Etienne Cimon wrote: On 2015-05-09 05:44, Baz wrote: On Saturday, 9 May 2015 at 06:21:11 UTC, extrawurst wrote: On Saturday, 9 May 2015 at 00:16:28 UTC, Etienne wrote: I'm trying to compile a library that I think used to work with -m32mscoff

Re: Spawning a console in Windows (similar to forkpty on linux)

2015-05-09 Thread Baz via Digitalmars-d-learn
On Saturday, 9 May 2015 at 13:01:27 UTC, wobbles wrote: On Saturday, 9 May 2015 at 13:00:01 UTC, wobbles wrote: On Saturday, 9 May 2015 at 12:48:16 UTC, Kagamin wrote: On Saturday, 9 May 2015 at 12:26:58 UTC, wobbles wrote: What I mean is, if the cmd.exe hasnt flushed it's output, my cmdPid.st

Re: mscoff x86 invalid pointers

2015-05-09 Thread Baz via Digitalmars-d-learn
On Saturday, 9 May 2015 at 06:21:11 UTC, extrawurst wrote: On Saturday, 9 May 2015 at 00:16:28 UTC, Etienne wrote: I'm trying to compile a library that I think used to work with -m32mscoff flag before I reset my machine configurations. https://github.com/etcimon/memutils Whenever I run `dub t

Re: Bitfield-style enum to strings?

2015-05-07 Thread Baz via Digitalmars-d-learn
On Thursday, 7 May 2015 at 17:41:10 UTC, Nick Sabalausky wrote: Assuming a plain old bitfield-style enum like: enum Foo { optionA = 1<<0; optionB = 1<<1; optionC = 1<<2; optionD = 1<<3; optionE = 1<<4; } Does a function already exist somewhere to take an instance of Foo and

Re: Efficiently passing structs

2015-05-03 Thread Baz via Digitalmars-d-learn
On Monday, 4 May 2015 at 01:58:12 UTC, bitwise wrote: The documentation doesn't say anything about "in" being a reference, but it doesn't say that "out" parameters are references either, even though it's usage in the example clearly shows that it is. Thanks, Bit http://dlang.org/function.h

why std.process.Pid & std.process.Environment are classes ?

2015-05-02 Thread Baz via Digitalmars-d-learn
In std.process, the following declarations: - final class Pid - abstract final class environment could be struct, couldn't they ? Any particular reason behind this choice ?

Re: Readonly-to-outside variable

2015-04-28 Thread Baz via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 19:30:06 UTC, tcak wrote: Is there any way to define a variable or an attribute as read-only without defining a getter function/method for it? Thoughts behind this question are: 1. For every reading, another function call process for CPU while it could directly rea

Re: std.json questions

2015-04-25 Thread Baz via Digitalmars-d-learn
On Saturday, 25 April 2015 at 09:56:25 UTC, tired_eyes wrote: I think this is ugly and clunky approach, what is the beautiful one? What you clearly need is a serializer: look at these: http://wiki.dlang.org/Libraries_and_Frameworks#Serialization and also: https://github.com/search?utf8=✓&q=

Re: Weird link error

2015-04-20 Thread Baz via Digitalmars-d-learn
On Monday, 20 April 2015 at 17:02:18 UTC, CodeSun wrote: And where I can find the D symbol definition, because information like ‘_D2tt2Ti12__T3getTAyaZ3getMFAyaZAya’ makes me really confused. --- import std.demangle; auto friendlySymbol = demangle("_D2tt2Ti12__T3getTAyaZ3getMFAyaZAya"); --

why cant function parameters be grouped by type ?

2015-04-12 Thread Baz via Digitalmars-d-learn
Hi, while variable declarations work in list: uint a,b,c; function parameters declarations don't: void foo(uint a,b,c); Because of this, function declarations are sometimes super-wide. (despite of the fact that: http://www.brainyquote.com/quotes/quotes/a/alanperlis177279.html) In the pr

Re: Specify an entire directory tree for string imports

2015-03-29 Thread Baz via Digitalmars-d-learn
On Monday, 30 March 2015 at 02:13:22 UTC, Alex Parrill wrote: I have a directory structure like this: . | test.d | \---test | test1.txt | \---subfolder test2.txt I am running test.d using this command:

Re: Format double in decimal notation without trailing zeros after the decimal point

2015-03-28 Thread Baz via Digitalmars-d-learn
On Friday, 27 March 2015 at 15:02:19 UTC, akaDemik wrote: The task seemed very simple. But I'm stuck. I want to: 1234567890123.0 to "1234567890123" 1.23 to "1.23" 1.234567 to "1.2346". With format string "%.4f" i get "1.2300" for 1.23. With "%g" i get "1.23456789e+12" for "1234567890123.0".

Re: Associative Array of Const Objects?

2015-03-28 Thread Baz via Digitalmars-d-learn
On Friday, 27 March 2015 at 21:33:19 UTC, bitwise wrote: class Test{} void main() { const(Test)[string] tests; tests["test"] = new Test(); } This code used to work, but after upgrading to dmd 2.067, it no longer does. --Error: cannot modify const expression tests["test"] How

Re: PrimitiveRef ?

2015-03-23 Thread Baz via Digitalmars-d-learn
On Monday, 23 March 2015 at 16:58:49 UTC, Andre wrote: Hi, " (needed for specifying reference behavior in a type tuple). I need exactly that behavior. I am currently unsure whether it is possible at all to have such a construct which works at user side exactly like a boolean (booleans can be

Re: Text UI for D?

2015-03-20 Thread Baz via Digitalmars-d-learn
On Friday, 20 March 2015 at 10:29:45 UTC, DLearner wrote: Does D have a recommended package for this - like (n)curses for C? I cannot recommend it because i've just found the package, it like Pascal turbo vision but in D. https://github.com/bbodi/dvision A few years ago someine else started

Re: chaining splitters

2015-03-11 Thread Baz via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 00:00:39 UTC, dnoob wrote: Hello, I am parsing some text and I have the following; string text = "some very long text"; foreach(line; splitter(text, [13, 10])) { foreach(record; splitter(line, '*')) { foreach(field; splitter(record

Re: What's the rationale here? alias this and function arguments

2015-03-10 Thread Baz via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 10:27:14 UTC, John Colvin wrote: struct S { int a; this(T)(T v) { this = v; } void foo(T)(T v) { import std.conv : to; a = v.to!int; } alias foo this; } vo

Re: string-int[] array

2015-03-08 Thread Baz via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:54:43 UTC, Meta wrote: On Sunday, 8 March 2015 at 18:38:02 UTC, Dennis Ritchie wrote: On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote: import std.stdio; import std.typecons; alias T = Tuple!(string, int); void main(string[] args) { T[] tarr; tarr ~= T(&q

Re: string-int[] array

2015-03-08 Thread Baz via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote: On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"]; using an array of tupl

Re: string-int[] array

2015-03-08 Thread Baz via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"]; using an array of tuple it works: import std.stdio; import std.typecons; alias T = Tuple!

UFCS on template alias ?

2015-02-21 Thread Baz via Digitalmars-d-learn
Is this a normal behaviour ? --- void main() { import std.algorithm; auto list = [0,1,2,3]; alias poly = map; list.poly!(a => a + a); } --- outputs: "Error: no property 'poly' for type 'int[]'"

Re: const member function

2015-02-21 Thread Baz via Digitalmars-d-learn
On Saturday, 21 February 2015 at 07:31:19 UTC, rumbu wrote: On Saturday, 21 February 2015 at 07:01:12 UTC, Baz wrote: --- class S { private SomeType cache; public const(SomeType) SomeProp() @property { if (cache is null) cache = SomeExpensiveOperation(); return

Re: const member function

2015-02-20 Thread Baz via Digitalmars-d-learn
--- class S { private SomeType cache; public const(SomeType) SomeProp() @property { if (cache is null) cache = SomeExpensiveOperation(); return cache; } } --- the result of the getter will be read-only

what is the offical way to handle multiple list in map() ?

2015-02-16 Thread Baz via Digitalmars-d-learn
while learning the map function, i've landed on this wikipedia page(http://en.wikipedia.org/wiki/Map_(higher-order_function)). For each language there is a column about handing multiple list, i thought it could be a good idea to see how D handle this: is this the official way ? --- auto fruit

Re: Wrong overload resolution

2015-02-15 Thread Baz via Digitalmars-d-learn
On Sunday, 15 February 2015 at 23:48:50 UTC, rumbu wrote: This problem appears only if one of the parameters is an interface. Without it or using any other type as a second parameter instead of the interface, it compiles. Also it compiles if the passed interface is null. The example below us

Re: Is there an object on given memory address?

2015-02-12 Thread Baz via Digitalmars-d-learn
On Thursday, 12 February 2015 at 11:14:05 UTC, tcak wrote: Or send a hash of the object along with the memory address, then query the GC wether the memory is still allocated. This part sounds interesnting. How does that GC querying thing works exactly? std [doc][1] is your friend but if you

Re: Wrong pointer calculation without casting on struct

2015-02-05 Thread Baz via Digitalmars-d-learn
On Friday, 6 February 2015 at 04:10:08 UTC, tcak wrote: On Friday, 6 February 2015 at 03:59:51 UTC, tcak wrote: I am on 64-bit Linux. I defined a struct that it 8 bytes in total. align(1) struct MessageBase{ align(1): ushort qc; ushort wc; ushort id; ushort cont

Re: Virtual functions and inheritance

2015-01-29 Thread Baz via Digitalmars-d-learn
even more weird: --- module test; import std.conv; interface Meh{ final string typeName() {return to!string(this);} } class Parent : Meh {} class Child : Parent {} void main() { auto p = new Parent; auto c = new Child; assert(p.typeName == __MODULE__ ~ ".Parent"); assert(c.typ

Re: Virtual functions and inheritance

2015-01-29 Thread Baz via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 04:38:59 UTC, David Monagle wrote: Hi guys, I'm a former C++ developer and really enjoying working with D now. I have a question that I hope some of you may be able to answer. class Parent { @property string typeName() { return typeof(this).stringof; }

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Baz via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:35:58 UTC, zhmt wrote: Anybody help? __Traits functions are evaluated at compile time so it's not as simple. The best you can do is to generate a string to mixin based on the aggragate members. here i have an example of how you can iterate through the memb

Re: Virtual functions and inheritance

2015-01-27 Thread Baz via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 08:19:46 UTC, Daniel Kozák wrote: You can use this T: class Parent { @property string typeName(this T)() { return T.stringof; } } class Child : Parent { } void main() { auto p = new Parent; auto c = new Child; assert(p.typeName == "Pa

Re: Some array casts

2015-01-21 Thread Baz via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 14:31:15 UTC, bearophile wrote: Currently this is accepted: int[2] m = cast(int[2])[1, 2]; But Kenji suggests that the cast from int[] to int[2][1] should not be accepted. Do you know why? Reference: https://issues.dlang.org/show_bug.cgi?id=7514 Bye and than

Re: Some array casts

2015-01-21 Thread Baz via Digitalmars-d-learn
On Wednesday, 21 January 2015 at 14:41:48 UTC, Baz wrote: On Wednesday, 21 January 2015 at 14:31:15 UTC, bearophile wrote: Currently this is accepted: int[2] m = cast(int[2])[1, 2]; But Kenji suggests that the cast from int[] to int[2][1] should not be accepted. Do you know why? Reference

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-07 Thread Baz via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 15:04:24 UTC, Paulo Pinto wrote: On Wednesday, 7 January 2015 at 15:02:34 UTC, Laeeth Isharc wrote: Not true. If you're using a tree structure, you *should* use pointers. Unless you're using classes, which are by-reference, in which case you can just use the c

Re: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows?

2015-01-07 Thread Baz via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 17:57:18 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Jan 07, 2015 at 05:16:13PM +, FrankLike via Digitalmars-d-learn wrote: >To hide the infos you can also (I've seen people say that you >can use >a packer) encrypt the strings and decode them at

Re: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows?

2015-01-07 Thread Baz via Digitalmars-d-learn
On Tuesday, 6 January 2015 at 17:15:28 UTC, FrankLike wrote: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows? If you build a exe ,such as which can get Data from DataBase,when you modify the exe's extension to 'txt', and you open it b

Re: getting all children classes in program

2015-01-03 Thread Baz via Digitalmars-d-learn
On Saturday, 3 January 2015 at 15:00:53 UTC, Ondra wrote: I'm not sure if there's a way around that other than to add some code in the class to register itself. You could use a static constructor that adds itself to a list. Or, to give each class a shared ID, you could add a static member

Re: readln with buffer fails

2014-10-29 Thread Baz via Digitalmars-d-learn
On Wednesday, 29 October 2014 at 21:14:17 UTC, dcrepid wrote: I have this simple code: int main() { import std.stdio; char[4096] Input; readln(Input); //readln!(char)(Input); // also fails return 0; } I get these messages during compilation: test.d(39): Error: template std.s

Re: More uses of operator "in"

2014-10-28 Thread Baz via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 16:32:13 UTC, Marc Schütz wrote: On Tuesday, 28 October 2014 at 15:11:01 UTC, Baz wrote: On Tuesday, 28 October 2014 at 13:50:24 UTC, Nordlöw wrote: Has there been any proposals/plans to make operator "in" work for elements in ranges such as assert(

Re: More uses of operator "in"

2014-10-28 Thread Baz via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 13:50:24 UTC, Nordlöw wrote: Has there been any proposals/plans to make operator "in" work for elements in ranges such as assert('x' in ['x']); I'm missing that Python feature when I work in D. There is also something similar in Pascal, at the language leve

Re: enum-indexed arrays

2014-09-20 Thread Baz via Digitalmars-d-learn
On Saturday, 20 September 2014 at 22:00:24 UTC, bearophile wrote: Nordlöw: should be Enumerator start = Enumerator.min This also requires the enum to have adjacent values (in general enums can skip values). Bye, bearophile Not true, because you can use std.traits.EnumMembers to prepa

Re: Using the delete Keyword /w GC

2014-08-25 Thread Baz via Digitalmars-d-learn
On Monday, 25 August 2014 at 17:10:11 UTC, Etienne wrote: People have been saying for quite a long time not to use the `delete` keyword on GC-allocated pointers. I've looked extensively through the code inside the engine and even made a few modifications on it/benchmarked it for weeks and I s

Produce some COFF object with 2.066 ?

2014-08-20 Thread Baz via Digitalmars-d-learn
Hello, I've been very interested about the announce saying that DMD is able to produce COFF object files. Mostly because I'm thinking using some objects programmed in D in a software programmed in another lang, a bit like when statically linking a dll to a program but with an obj, to keep a nic

Re: Destroy two assumptions: interface implementation generated by TMP

2014-08-12 Thread Baz via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 12:43:46 UTC, anonymous wrote: On Tuesday, 12 August 2014 at 12:08:14 UTC, John Colvin wrote: I think the problem is that impl3.tmp is not virtual because it's a template, and interfaces need to be implemented by virtual methods. The instantiations of the templat

Destroy two assumptions: interface implementation generated by TMP

2014-08-11 Thread Baz via Digitalmars-d-learn
Hi, I try to get why the last way of generating an interface implementation fails. I've put assumptions: is it right ? --- module itfgen; import std.stdio; interface itf{ void a_int(int p); void a_uint(uint p); } template genimpl(T){ char[] genimpl(){

Re: Preferred program config file format and parsing library?

2014-08-05 Thread Baz via Digitalmars-d-learn
https://en.wikipedia.org/wiki/Marshalling_(computer_science) bla. damn it.

Re: Preferred program config file format and parsing library?

2014-08-05 Thread Baz via Digitalmars-d-learn
On Saturday, 2 August 2014 at 12:42:00 UTC, Gary Willoughby wrote: What is the preferred format people here use for program config files? Json, Xml, ini, etc? Also what libraries exist to parse the preferred format? Preffered one is the one a RTL(run time library) or a VCL(visual component l

Re: Reuse C memory for D struct?

2013-11-22 Thread Baz
On Thursday, 21 November 2013 at 15:22:10 UTC, Lemonfiend wrote: Hi! I'm wondering if it's possible to have a struct in D which uses the same pointer and memory as returned by the extern C function. This would allow me to manipulate and use the C struct directly in D code. I'm not sure how

Re: Class References

2013-11-22 Thread Baz
On Monday, 28 October 2013 at 11:22:03 UTC, Jeroen Bollen wrote: Is it possible in D to create an enum of class references? Something around the lines of: enum ClassReferences : Interface { CLASS1 = &ClassOne, CLASS2 = &ClassTwo } at runtime make an array of *void and cast them accordi

Re: Source code of a method.

2013-11-07 Thread Baz
On Thursday, 7 November 2013 at 17:31:45 UTC, Baz wrote: On Monday, 4 November 2013 at 19:50:22 UTC, Baz wrote: On Monday, 4 November 2013 at 18:00:17 UTC, Baz wrote: On Monday, 4 November 2013 at 16:42:42 UTC, Jacob Carlborg wrote: On 2013-11-04 16:09, Baz wrote: On Saturday, 26 October 2013

Re: Source code of a method.

2013-11-07 Thread Baz
On Monday, 4 November 2013 at 19:50:22 UTC, Baz wrote: On Monday, 4 November 2013 at 18:00:17 UTC, Baz wrote: On Monday, 4 November 2013 at 16:42:42 UTC, Jacob Carlborg wrote: On 2013-11-04 16:09, Baz wrote: On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle wrote: Is there a way

Re: ddoc doesn't generate entries of function without any comments?

2013-11-04 Thread Baz
On Monday, 4 November 2013 at 22:22:07 UTC, Flamaros wrote: I need dig into some low level APIs regularly. Modules like std.c.window and std.c.linux doesn't have any documentation about what it's contains. I also try to generate some docs with ddoc on my project and it seems it doesn't create

Re: Source code of a method.

2013-11-04 Thread Baz
On Monday, 4 November 2013 at 18:00:17 UTC, Baz wrote: On Monday, 4 November 2013 at 16:42:42 UTC, Jacob Carlborg wrote: On 2013-11-04 16:09, Baz wrote: On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle wrote: Is there a way to extract the source code of a method at compiletime

Re: Source code of a method.

2013-11-04 Thread Baz
On Monday, 4 November 2013 at 16:42:42 UTC, Jacob Carlborg wrote: On 2013-11-04 16:09, Baz wrote: On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle wrote: Is there a way to extract the source code of a method at compiletime? Yep, at least on win32. (tested in win7 32 with DEP set

Re: Source code of a method.

2013-11-04 Thread Baz
On Monday, 4 November 2013 at 15:09:38 UTC, Baz wrote: On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle wrote: Is there a way to extract the source code of a method at compiletime? Yep, at least on win32. (tested in win7 32 with DEP set to "ON" for everythi

Re: Source code of a method.

2013-11-04 Thread Baz
On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle wrote: Is there a way to extract the source code of a method at compiletime? Yep, at least on win32. (tested in win7 32 with DEP set to "ON" for everything) http://dpaste.dzfl.pl/19c77eee It doesn't run on DPaste (linux x86_64) t

Re: Payload structure problem using inline asm

2013-07-18 Thread Baz
On Wednesday, 17 July 2013 at 18:04:38 UTC, Baz wrote: On Wednesday, 17 July 2013 at 17:11:20 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 17:09:30 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 16:52:40 UTC, Baz wrote: Hello, I've defined a simple template used in a d

Re: "Previous Definition different" when -inline switch is set

2013-07-17 Thread Baz
On Wednesday, 17 July 2013 at 18:00:47 UTC, Jonathan M Davis wrote: On Wednesday, July 17, 2013 16:01:23 Baz wrote: Is the bug described a "well known" issue with a "well known" workaround ? (so far, I haven't found anything which is related, even with some serious foru

Re: Payload structure problem using inline asm

2013-07-17 Thread Baz
On Wednesday, 17 July 2013 at 17:11:20 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 17:09:30 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 16:52:40 UTC, Baz wrote: Hello, I've defined a simple template used in a double linked list implementation: template tDLListI

Payload structure problem using inline asm

2013-07-17 Thread Baz
Hello, I've defined a simple template used in a double linked list implementation: template tDLListItem(T) { const cPrevOffs = size_t.sizeof; const cNextOffs = size_t.sizeof + size_t.sizeof; void* NewItemCaps(T* aData, void* aPrevious, void* aNext) {

"Previous Definition different" when -inline switch is set

2013-07-17 Thread Baz
Hello, is there any particular reason why dmd would tell me that the "Previous Definition different" when compiling a program with -inline while not when compiling it without the switch ? more information: - the message appears two times and it's about two methods used in a lib. - the message