Re: array/Array: "hard" bounds checking

2018-02-22 Thread bauss via Digitalmars-d-learn
On Thursday, 22 February 2018 at 05:22:19 UTC, TheFlyingFiddle wrote: Eg: uint a = 3; int b = -1; assert(a > b); //No idea what should happen here. This is what happens: assert(cast(int)a > b);

Generic Property Implementation

2018-02-20 Thread bauss via Digitalmars-d-learn
Would there be a reason why this wouldn't be a good implementation? If so what and how could it be improved? Are there flaws in an implementation like this? struct Property(T, bool readOnly = false) { import std.traits : isScalarType, isArray, isAssociativeArray, isSomeString;

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread bauss via Digitalmars-d-learn
On Friday, 16 February 2018 at 13:08:09 UTC, bauss wrote: On Friday, 16 February 2018 at 12:15:07 UTC, arturg wrote: On Friday, 16 February 2018 at 11:45:21 UTC, arturg wrote: this code fails to compile: void delegate(void*) dg; void delegate(void*)[] dgs = [dg, dg, dg];

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread bauss via Digitalmars-d-learn
On Friday, 16 February 2018 at 12:15:07 UTC, arturg wrote: On Friday, 16 February 2018 at 11:45:21 UTC, arturg wrote: this code fails to compile: void delegate(void*) dg; void delegate(void*)[] dgs = [dg, dg, dg]; dgs.writeln; dgs.remove(1).writeln(); if you comment out

Re: How to check if aggregate member is static templated method?

2018-02-16 Thread bauss via Digitalmars-d-learn
On Thursday, 15 February 2018 at 15:49:47 UTC, RazvanN wrote: On Thursday, 15 February 2018 at 13:51:41 UTC, drug wrote: 15.02.2018 16:50, drug пишет: https://run.dlang.io/is/zHT2XZ I can check againts if member is either static function or template. But I failed to check if it both static

Re: getSymbolsByUDA does not take private symbols under consideration. Should I file a bug?

2018-02-16 Thread bauss via Digitalmars-d-learn
On Friday, 16 February 2018 at 09:26:47 UTC, Piotr Mitana wrote: Hello, The code below: import std.traits; enum Attr; class MyClass { private @Attr int a; static assert(getSymbolsByUDA!(typeof(this), MyClass).length == 1); } does not compile as

Re: import strangeness with std.stdio.write

2018-02-13 Thread bauss via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 13:56:17 UTC, psychoticRabbit wrote: On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole wrote: On 13/02/2018 1:46 PM, psychoticRabbit wrote: So, strange problem below. The commented-out line will not compile (if I un-comment it), unless I either

Re: How to imporve D-translation of these Python list comprehensions ?

2018-02-01 Thread bauss via Digitalmars-d-learn
On Thursday, 1 February 2018 at 11:59:23 UTC, Russel Winder wrote: On Mon, 2018-01-15 at 21:13 +, lobo via Digitalmars-d-learn wrote: On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: > A workmate has recently shown this piece of code to show how > nice Python is (we are mostly C

Re: Discarded return values

2018-01-30 Thread bauss via Digitalmars-d-learn
On Tuesday, 30 January 2018 at 10:49:54 UTC, Simen Kjærås wrote: Is there a way to get a compile error when returning a temporary from a function and then not assigning it to a variable or passing it to a different function? E.g: struct S { int[] a; void morph() {} } @warnOnDiscard S

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread bauss via Digitalmars-d-learn
On Thursday, 21 December 2017 at 19:43:16 UTC, Steven Schveighoffer wrote: On 12/20/17 9:57 PM, Mike Franklin wrote: [...] It's implementation defined :) The gist is, you cannot expect that destructors will be run in a timely manner, or at all. They may be called, and most of the time

Re: can't run libuid examples

2017-12-21 Thread bauss via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:41:28 UTC, greatsam4sure wrote: I am having problem with running the examples of libuid on Windows and how to use libuid on a project without errors. I am using dmd version 2.076 Okay, but how are we supposed to help if you don't show us what errors you

Re: WARN on implicit super?

2017-12-21 Thread bauss via Digitalmars-d-learn
On Thursday, 21 December 2017 at 06:47:25 UTC, Ali Çehreli wrote: On 12/20/2017 10:36 PM, Chris Katko wrote: Is there any way to get a warning anytime an implicit super constructor is called in a sub-class/child-class? There can be a number of solutions but can you please demonstrate the

Re: DateTime formatting

2017-12-20 Thread bauss via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 22:38:06 UTC, Jonathan M Davis wrote: On Wednesday, December 20, 2017 21:36:00 bauss via Digitalmars-d-learn wrote: On Wednesday, 20 December 2017 at 18:50:37 UTC, Jonathan M Davis wrote: > On Wednesday, December 20, 2017 14:30:55 bauss via > > Digi

Re: DateTime formatting

2017-12-20 Thread bauss via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 18:50:37 UTC, Jonathan M Davis wrote: On Wednesday, December 20, 2017 14:30:55 bauss via Digitalmars-d-learn wrote: I can't seem to find anything in Phobos that allows you to specify custom formats for dates. Am I on my own or is there already

DateTime formatting

2017-12-20 Thread bauss via Digitalmars-d-learn
I can't seem to find anything in Phobos that allows you to specify custom formats for dates. Am I on my own or is there already such functionality? I'm interested in a formatter with the possibility to output ex.: December 20th, 2017 10:00 AM All I could find was toSimpleString(), but it

Alias!T

2017-12-16 Thread bauss via Digitalmars-d-learn
In what scenario would you use Alias!T from std.meta? I understand what it does and how it can be used, but I can't seem to think of a reasonable situation where it's desirable.

Re: weird exception on windows

2017-12-16 Thread bauss via Digitalmars-d-learn
On Saturday, 16 December 2017 at 08:07:30 UTC, Szabo Bogdan wrote: On Friday, 15 December 2017 at 21:56:48 UTC, Steven Schveighoffer wrote: On 12/15/17 10:08 AM, Kagamin wrote: Maybe this https://issues.dlang.org/show_bug.cgi?id=18084 Thanks for looking into this. I created a PR to fix.

Re: What's the proper way to use std.getopt?

2017-12-13 Thread bauss via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 07:37:17 UTC, Jonathan M Davis wrote: On Wednesday, December 13, 2017 06:55:46 bauss via Digitalmars-d-learn wrote: [...] If it works, it's a bug related to code lowering (since scope statements are always lowered to try-catch-finally blocks). You're

Re: What's the proper way to use std.getopt?

2017-12-12 Thread bauss via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 18:34:26 UTC, Mike Wey wrote: On 12-12-17 00:35, Seb wrote: D style would be to use sth. like this (instead of try/catch): ``` scope(failure) {   e.msg.writeln;   1.exit; } ``` I might have missed something, but where is `e` defined in this case? I was

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread bauss via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 22:11:37 UTC, Adam D. Ruppe wrote: On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote: The same buffer is used for all segments and socket.receive should be inside while. The buffer is copied by the ~= operator, but indeed you're right that I

Re: Abstract Classes

2017-12-06 Thread bauss via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 07:23:29 UTC, IM wrote: Assume the following: interface IFace { void foo(); void bar(); } abstract class A : IFace { override void foo() {} } class B : A { override void bar() {} } Now why this fails to compiler with the following message: --->>>

Re: Object oriented programming and interfaces

2017-12-05 Thread bauss via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 08:08:55 UTC, Daniel Kozak wrote: You can do something like this: interface Medoid(T) { float distance( T other ); uint id() const @property; } class Item : Medoid!(Item) { float distance( Item m ) { return 0.;} uint id() const @property { return

Re: Struct inside a class: How to get outer?

2017-12-03 Thread bauss via Digitalmars-d-learn
On Sunday, 3 December 2017 at 07:38:47 UTC, Jonathan M Davis wrote: On Sunday, December 03, 2017 01:05:00 Nick Sabalausky via Digitalmars-d- learn wrote: Is this even possible? My attempts: class Outer { struct Inner { void foo() { // Error: no property 'outer' for type

Re: Is variable void?

2017-11-27 Thread bauss via Digitalmars-d-learn
On Monday, 27 November 2017 at 02:12:40 UTC, codephantom wrote: On Saturday, 25 November 2017 at 15:34:21 UTC, John Chapman wrote: Is there any way of determining whether a variable has been initialized or not? For example, if something is declared like this: int x = void; can I check if

Re: dub: Use Alternate Dependency

2017-11-20 Thread bauss via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 02:51:13 UTC, jmh530 wrote: I'm working on two related dub projects on code.dlang.org. One has a dependency on the other. However, I've made changes to both and to run the tests properly requires me to use both versions in my working directory, rather than the

Re: Json

2017-11-19 Thread bauss via Digitalmars-d-learn
On Sunday, 19 November 2017 at 10:50:58 UTC, Mafi wrote: On Saturday, 18 November 2017 at 14:25:58 UTC, kerdemdemir wrote: I am using vibe.d's json(http://vibed.org/api/vibe.data.json/) module without a problem and really happy with it. There are also some

Re: Json

2017-11-18 Thread bauss via Digitalmars-d-learn
On Friday, 17 November 2017 at 19:12:04 UTC, Jonathan M Davis wrote: On Friday, November 17, 2017 19:02:12 Mafi via Digitalmars-d-learn wrote: [...] I've typically used http://code.dlang.org/packages/std_data_json which comes from vibe.d and was a candidate for replacing std.json - though

Re: ESR on post-C landscape

2017-11-15 Thread Bauss via Digitalmars-d-learn
On Thursday, 16 November 2017 at 02:12:10 UTC, codephantom wrote: On Tuesday, 14 November 2017 at 11:55:17 UTC, codephantom wrote: [...] Actually, I got that wrong. Perhaps the mistake C++ made, was concluding that 'classes' were the "proper primary focus of program design" (chp1. The

Re: ESR on post-C landscape

2017-11-14 Thread bauss via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 04:31:43 UTC, Laeeth Isharc wrote: He mentions D, a bit dismissively. http://esr.ibiblio.org/?p=7724=1#comment-1912717 Couldn't read that without cringing.

Re: opCast'ing strings

2017-11-13 Thread bauss via Digitalmars-d-learn
On Monday, 13 November 2017 at 01:12:59 UTC, Adam D. Ruppe wrote: On Monday, 13 November 2017 at 01:03:17 UTC, helxi wrote: In this program, casting using to does not work as intended (returning 23/11) on the struct. However, calling opCast directly seems to do the job. Why is that?

Re: How do I create a fileWatcher with an onFileChange event using spawn?

2017-11-13 Thread bauss via Digitalmars-d-learn
On Monday, 28 August 2017 at 11:25:03 UTC, Jacob Carlborg wrote: On 2017-08-28 08:31, Nemanja Boric wrote: On Monday, 28 August 2017 at 06:27:20 UTC, Jacob Carlborg wrote: http://code.dlang.org/packages/vibe-core http://code.dlang.org/packages/libasync In addition, to avoid polling, it's

Re: convert string to ubyte[]

2017-11-11 Thread bauss via Digitalmars-d-learn
On Saturday, 11 November 2017 at 15:48:59 UTC, Mike Parker wrote: On Saturday, 11 November 2017 at 15:38:18 UTC, aki wrote: [...] I don't know about the error you're seeing, but the generic way to get an array of the underlying data type of a string is via std.string.representation.

Re: Synchronize Class fields between different threads

2017-11-10 Thread bauss via Digitalmars-d-learn
On Friday, 10 November 2017 at 14:36:03 UTC, DrCataclysm wrote: On Friday, 10 November 2017 at 14:27:41 UTC, bauss wrote: On Friday, 10 November 2017 at 14:13:26 UTC, DrCataclysm wrote: On Friday, 10 November 2017 at 13:50:56 UTC, rikki cattermole wrote: Remember this bit: Everything on the

Re: Synchronize Class fields between different threads

2017-11-10 Thread bauss via Digitalmars-d-learn
On Friday, 10 November 2017 at 15:01:30 UTC, bauss wrote: On Friday, 10 November 2017 at 14:36:03 UTC, DrCataclysm wrote: On Friday, 10 November 2017 at 14:27:41 UTC, bauss wrote: On Friday, 10 November 2017 at 14:13:26 UTC, DrCataclysm wrote: [...] _client is allocated in the heap. Socket

Re: Synchronize Class fields between different threads

2017-11-10 Thread bauss via Digitalmars-d-learn
On Friday, 10 November 2017 at 14:13:26 UTC, DrCataclysm wrote: On Friday, 10 November 2017 at 13:50:56 UTC, rikki cattermole wrote: Remember this bit: Everything on the heap, is not thread-local, it is global. This includes everything inside a class. When you synchronize (statement) it is

Re: How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

2017-11-08 Thread bauss via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 03:48:58 UTC, codephantom wrote: On Wednesday, 8 November 2017 at 03:33:08 UTC, bauss wrote: -- Compiles fine with DMD: https://dpaste.dzfl.pl/95b896aa242f ahh.. that site saves it with

Re: How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

2017-11-07 Thread bauss via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 03:05:22 UTC, codephantom wrote: On Tuesday, 7 November 2017 at 21:32:26 UTC, Adam D. Ruppe wrote: [...] it's interesting how the compiler deals with scope. --- // save this in a file

Re: Issues with Vibe.d Dynamic HTML with JSON

2017-11-02 Thread bauss via Digitalmars-d-learn
On Thursday, 2 November 2017 at 18:48:10 UTC, bauss wrote: On Thursday, 2 November 2017 at 16:23:55 UTC, SamwiseFilmore wrote: On Thursday, 2 November 2017 at 08:40:28 UTC, bauss wrote: [...] No, the html does come in, and the whole content of the rendered page is sent to the browser. The

Re: Issues with Vibe.d Dynamic HTML with JSON

2017-11-02 Thread bauss via Digitalmars-d-learn
On Thursday, 2 November 2017 at 16:23:55 UTC, SamwiseFilmore wrote: On Thursday, 2 November 2017 at 08:40:28 UTC, bauss wrote: Do you get a response back with rendered html or does the connection get dropped? No, the html does come in, and the whole content of the rendered page is sent to

Re: Issues with Vibe.d Dynamic HTML with JSON

2017-11-02 Thread bauss via Digitalmars-d-learn
On Thursday, 2 November 2017 at 04:00:10 UTC, SamwiseFilmore wrote: I've got a serialized JSON structure that looks something like this: [...] Do you get a response back with rendered html or does the connection get dropped? Have you tried to cut down the amount of data and see if it will

Re: "version" private word

2017-10-31 Thread bauss via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 13:55:56 UTC, Igor Shirkalin wrote: On Tuesday, 31 October 2017 at 13:53:54 UTC, Jacob Carlborg wrote: On 2017-10-31 14:46, Igor Shirkalin wrote: Hello! We need some conditional compilation using 'version'. Say we have some code to be compiled for X86 and

Re: Empty UDA for classes not allowed?

2017-10-26 Thread bauss via Digitalmars-d-learn
On Thursday, 26 October 2017 at 21:24:43 UTC, Jonathan M Davis wrote: On Thursday, October 26, 2017 15:09:48 bauss via Digitalmars-d-learn wrote: [...] It worked just fine when I just tried it on my machine - both with dmd master and with 2.076.1. Are you using an older version

Empty UDA for classes not allowed?

2017-10-26 Thread bauss via Digitalmars-d-learn
Why is it not allowed to have empty UDAs for classes? Let's say we have an UDA like this: struct Exclude { } Then we want to put it on a class like: @Exclude class Foo { ... } This will fail with the following error: Error: type Exclude has no value But on everything else we can place an

Re: Garbage Collector profiling and the dynamic array reserve() function

2017-10-22 Thread bauss via Digitalmars-d-learn
On Wednesday, 18 October 2017 at 15:39:43 UTC, Steven Schveighoffer wrote: On 10/18/17 1:40 AM, Tony wrote: On Tuesday, 17 October 2017 at 13:27:24 UTC, Steven Schveighoffer wrote: I don't know what "allocations" represents, but reserve actually calls gc_malloc, and the others do not (the

Re: Static if on release build

2017-10-19 Thread bauss via Digitalmars-d-learn
On Friday, 20 October 2017 at 02:36:37 UTC, Fra Mecca wrote: I can't find any documentation regarding conditional compilation in release and debug mode. I have read the page regarding the topicon dlang.org but adding the snippet below makes no difference when compiling with dub -b release {

Re: Does D have an equivalent to C#'s String.IsNullOrWhiteSpace?

2017-10-13 Thread bauss via Digitalmars-d-learn
On Thursday, 12 October 2017 at 18:17:54 UTC, Adam D. Ruppe wrote: On Thursday, 12 October 2017 at 18:11:55 UTC, Nieto wrote: Does D have an equivalent to C#'s String.IsNullOrWhiteSpace() in the standard library? import std.string; if(str.strip().length == 0) { // is null, empty, or all

Re: How to call function with variable arguments at runtime?

2017-10-10 Thread bauss via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 02:58:45 UTC, Mr. Jonse wrote: I need to store a hetrogeneous array of delegates. How can I do this but still call the function with the appropriate number of parameters at run time? I have the parameters as Variant[] params and a function/delegate

Re: How to make commented code to compile?

2017-10-10 Thread bauss via Digitalmars-d-learn
On Monday, 9 October 2017 at 15:22:54 UTC, Adam D. Ruppe wrote: On Monday, 9 October 2017 at 15:15:48 UTC, Zhuo Nengwen wrote: test(cast(ushort) 1, (m, c) => { writeln(m); writeln(m); }); Just remove the => (m, c) { // code here } Common mistake from people who worked with LINQ in

Re: High-level wrapper for readline package

2017-09-07 Thread bauss via Digitalmars-d-learn
On Thursday, 7 September 2017 at 14:00:36 UTC, Nordlöw wrote: On Thursday, 7 September 2017 at 13:44:52 UTC, Adam D. Ruppe wrote: [...] There's always room for usability improvements when wrapping C APIs... [...] Isn't it pointless to make "prompt" in?

Re: Web servers in D

2017-09-02 Thread bauss via Digitalmars-d-learn
On Saturday, 2 September 2017 at 20:18:17 UTC, bauss wrote: On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote: [...] Here is another template engine that can be used along with vibe. I actually made it for the same reason you don't wanna use vibe. Because I didn't like the

Re: Web servers in D

2017-09-02 Thread bauss via Digitalmars-d-learn
On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote: What libraries are people using to run webservers other than vibe.d? Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd. I think for D

Re: opEquals nothrow

2017-07-20 Thread bauss via Digitalmars-d-learn
On Thursday, 20 July 2017 at 14:38:03 UTC, Aldo wrote: Hello, im tring to add nothrow keyword in my code, but compilation fails : function 'object.opEquals' is not nothrow its a simple comparison between 2 objects. How to make opEquals nothrow ? thanks Could you show some code.

Re: Base class' constructor is not implicitly inherited for immutable classes. A bug or a feature?

2017-07-20 Thread bauss via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 16:00:56 UTC, Piotr Mitana wrote: Hello, I have this code: immutable class Base { this() {} } immutable class Derived : Base {} void main() { new immutable Derived(); } I'd like class Derived to automatically inherit the default constructor from

Re: D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-19 Thread bauss via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 15:18:00 UTC, Steven Schveighoffer wrote: On 7/17/17 10:21 PM, Enjoys Math wrote: DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I

Auto-decoding

2017-07-14 Thread bauss via Digitalmars-d-learn
I understand what it is and how it works, but I don't understand anything of how it solves any problems? Could someone give an example of when auto-decoding actually is useful in contrast to not using it? Just trying to get an understanding of what exactly its purpose is. I did read

Re: Need help to get OpenSSL 64 work on Windows x64 | I hate D's GC!

2017-07-14 Thread bauss via Digitalmars-d-learn
On Friday, 14 July 2017 at 13:16:17 UTC, Suliman wrote: It's look that GC in D is really suxx. There is already second toy-project where I am getting stuck on Windows with D for last 3 month. I'm using 32-bit build, because I can't understand which libs I should use to get OpenSSL 64 bit

Re: Fiber based UI-Toolkit

2017-07-10 Thread bauss via Digitalmars-d-learn
On Monday, 10 July 2017 at 08:40:15 UTC, Jacob Carlborg wrote: On 2017-07-09 23:12, bauss wrote: I believe OSX (possibly macOS too.) only allows it from the main thread. Yes, that's correct. But what's the difference between OSX and macOS ;) Well besides that it's newer versions of the

Re: Fiber based UI-Toolkit

2017-07-09 Thread bauss via Digitalmars-d-learn
On Sunday, 9 July 2017 at 19:43:14 UTC, Christian Köstlin wrote: I wonder if there is any fiber based / fiber compatible UI-Toolkit out for dlang. The second question is, if it would make sense at all to have such a thing? christian It doesn't really make sense to have that, because most

Re: Application settings

2017-07-07 Thread bauss via Digitalmars-d-learn
On Friday, 7 July 2017 at 22:52:22 UTC, FoxyBrown wrote: On Friday, 7 July 2017 at 20:45:36 UTC, Moritz Maxeiner wrote: On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then

Re: Panda Antivirus puts the latest dmd installer in quarantine

2017-07-06 Thread bauss via Digitalmars-d-learn
On Thursday, 6 July 2017 at 18:33:35 UTC, Ecstatic Coder wrote: But no problem with any file stored inside the current .7z archive file. So I guess the problem comes from the installer executable itself. Please try to fix this as soon as possible, as this immediately drives people away

Re: Finding all the interfaces and their inheritance relationships at runtime

2017-07-03 Thread bauss via Digitalmars-d-learn
On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote: I know how to find all the classes: foreach (mod; ModuleInfo) { foreach (c; mod.localClasses) { // use c.base to construct inheritance graph } } Can I do the same with all the interfaces? Looking at

Re: ReadProcessMemory + address from ollydbg

2017-07-01 Thread bauss via Digitalmars-d-learn
On Saturday, 1 July 2017 at 00:48:01 UTC, bauss wrote: On Saturday, 1 July 2017 at 00:40:11 UTC, ag0aep6g wrote: [...] Yeah, the cast was unnecessary. So this is my code after the changes: string ReadWinString(HANDLE process, DWORD address, size_t stringSize, string defaultValue = "") {

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Saturday, 1 July 2017 at 00:40:11 UTC, ag0aep6g wrote: On 07/01/2017 02:30 AM, bauss wrote: On Saturday, 1 July 2017 at 00:23:36 UTC, ag0aep6g wrote: On 07/01/2017 01:41 AM, bauss wrote: [...] if (!ReadProcessMemory(process, cast(PCVOID)address, cast(PVOID), The second cast

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Saturday, 1 July 2017 at 00:23:36 UTC, ag0aep6g wrote: On 07/01/2017 01:41 AM, bauss wrote: string ReadWinString(HANDLE process, DWORD address, size_t stringSize, string defaultValue = "") { if (!process || !address) { return defaultValue; } SIZE_T bytesRead; char[1024]

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 23:56:10 UTC, Stefan Koch wrote: On Friday, 30 June 2017 at 23:53:19 UTC, bauss wrote: I suspect the address is wrong, but it's the static address I picked up from ollydbg, so I'm kinda lost as for how ollydbg can get the correct string and I get the wrong one

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 23:41:19 UTC, bauss wrote: On Friday, 30 June 2017 at 21:36:25 UTC, ag0aep6g wrote: On Friday, 30 June 2017 at 20:14:15 UTC, bauss wrote: [...] I guess the first cast is necessary when `address` isn't typed as a pointer yet. But the other casts shouldn't be

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 21:36:25 UTC, ag0aep6g wrote: On Friday, 30 June 2017 at 20:14:15 UTC, bauss wrote: This is my definition: BOOL ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead); And I'm reading it like this: if

ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
I'm currently getting garbage data when using ReadProcessMemory to read from another process. This is my definition: BOOL ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead); And I'm reading it like this: if

Re: Get Function Body

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:43:33 UTC, Stefan Koch wrote: On Friday, 30 June 2017 at 16:38:45 UTC, bauss wrote: Is there a way to retrieve the body of a function as a string? Scenario. I want to pass a function to a mixin template and just mixin the body of the function. Ex. mixin

Get Function Body

2017-06-30 Thread bauss via Digitalmars-d-learn
Is there a way to retrieve the body of a function as a string? Scenario. I want to pass a function to a mixin template and just mixin the body of the function. Ex. mixin template Foo(alias fun) { void bar() { mixin(getBodyOfFun(fun)); } } I'm aware that I can pass a string

Re: Advice wanted on garbage collection of sockets for c++ programmer using D

2017-06-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 10:14:16 UTC, Jonathan M Davis wrote: On Tuesday, June 27, 2017 09:54:19 John Burton via Digitalmars-d-learn wrote: [...] Arguably, std.socket should have used structs instead of classes for sockets for precisely this reason (though there are some advantages in

Re: Clean Executable

2017-06-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 14:21:50 UTC, FoxyBrown wrote: How can we clean an exe from the junk library functions that are not actually used by an app. e.g., a hello world program shouldn't be 500+kb. I release there are necessary extras like the GC, but hell, in a hello world program is it

Re: GDC generate wrong .exe ("not a valid win32 application")

2017-06-22 Thread bauss via Digitalmars-d-learn
On Wednesday, 21 June 2017 at 15:55:27 UTC, David Nadlinger wrote: On Monday, 19 June 2017 at 14:08:56 UTC, Patric Dexheimer wrote: Fresh install of GDC. (tried with 32x ad 32_64x) Where did you get the GDC executable from? The GDC project doesn't currently offer any official builds that

Re: Which editor to use for editing DDOCs?

2017-05-23 Thread bauss via Digitalmars-d-learn
On Tuesday, 23 May 2017 at 07:40:21 UTC, biocyberman wrote: On Monday, 22 May 2017 at 15:33:36 UTC, Russel Winder wrote: [...] Adding DDOC support for D Mode require some more work obviously. I will see if I can make some changes to that. For the time being, I would like to know which

Re: Cheetah: Keeping track of multiple connected clients

2017-05-18 Thread bauss via Digitalmars-d-learn
On Thursday, 18 May 2017 at 11:44:57 UTC, aberba wrote: On Tuesday, 16 May 2017 at 21:56:16 UTC, aberba wrote: On Tuesday, 16 May 2017 at 17:49:07 UTC, bauss wrote: [...] It really awesome the way you responded quickly. About targeting a client, suppose I have clients A, B, and C. Message

Re: D equivalent of C++11's function local static initialization?

2017-05-17 Thread bauss via Digitalmars-d-learn
On Wednesday, 17 May 2017 at 03:08:39 UTC, Timothee Cour wrote: NOTE: curious about both cases: * thread local * shared On Tue, May 16, 2017 at 8:04 PM, Timothee Cour wrote: what's the best D equivalent of C++11's function local static initialization? ``` void

Re: Cheetah: Keeping track of multiple connected clients

2017-05-16 Thread bauss via Digitalmars-d-learn
On Tuesday, 16 May 2017 at 16:01:49 UTC, aberba wrote: Does anyone know how to keep track of multiple clients in Cheetah socket lib such that one can directly message a client or broadcast to all connected clients. Something like: onMessage(... e) { ... // send to all

Re: avoid extra variable during void pointer cast

2017-05-15 Thread Bauss via Digitalmars-d-learn
On Sunday, 14 May 2017 at 21:07:36 UTC, Marco Leise wrote: Am Sun, 14 May 2017 20:18:24 + schrieb Kevin Brogan : [...] No, that is not possible. An alias can only be assigned a symbol. [...] Let the compiler optimize the assignment away and don't worry much about

Re: How to declare "abstract" delegates list?

2017-05-06 Thread bauss via Digitalmars-d-learn
On Saturday, 6 May 2017 at 06:07:01 UTC, bauss wrote: On Friday, 5 May 2017 at 14:20:43 UTC, RedCAT wrote: [...] I would do something like this: [...] You could also do use alias this to use the delegate instead of the class encapsulating the delegate.

Re: How to declare "abstract" delegates list?

2017-05-06 Thread bauss via Digitalmars-d-learn
On Friday, 5 May 2017 at 14:20:43 UTC, RedCAT wrote: Hello! Is it possible to create a list of slightly different delegates? For example, there is a class hierarchy: class Base; class DerivedOne : Base; class DerivedTwo : Base; And there are several delegates: void delegate(int, Base); void

Re: Productive vibe.d dev environment (IDE, debugger) on Linux?

2017-05-04 Thread bauss via Digitalmars-d-learn
On Wednesday, 3 May 2017 at 17:43:07 UTC, kinke wrote: Hey guys, can anyone recommend a more or less production-ready dev environment for vibe.d on Linux? I'm evaluating vibe.d against Phoenix (Elixir/Erlang) for a new project. Today I gave Visual Studio Code a quick shot (with LDC 1.1.1 and

Re: String Comparison Operator

2017-04-30 Thread bauss via Digitalmars-d-learn
On Sunday, 30 April 2017 at 16:15:41 UTC, Xinok wrote: On Sunday, 30 April 2017 at 15:31:39 UTC, Jolly James wrote: Is there a String Comparison Operator in D? Yeah, just the usual comparison operators: "abc" == "abc" "abc" != "ABC" ~ is for string concatenation, i.e.: "abc" ~ "def" ==

Re: alias can't find symbol or can't use symbol

2017-04-29 Thread bauss via Digitalmars-d-learn
On Sunday, 30 April 2017 at 00:17:37 UTC, Carl Sturtivant wrote: Consider the following. struct member { int n; } struct outer { member x; alias x this; alias n2 = n; } This does not compile: alias n2 = n; Error: undefined identifier 'n' On the other hand if change that into

Re: Why is this legal?

2017-03-30 Thread bauss via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 10:08:02 UTC, abad wrote: Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement them anywhere, so is this also on purpose and on what rationale? :) That is not necessarily true. Final doesn't imply it can't be

Re: How to continue after the book?

2017-03-28 Thread bauss via Digitalmars-d-learn
On Tuesday, 28 March 2017 at 07:27:31 UTC, I Lindström wrote: After getting the basics down, how did you continue when learning programming in general? I do have a need for which I've been trying out a few languages and D seems by far the best for me. Should I just start doing that project

Re: Howto catch SocketOSException?

2017-03-26 Thread bauss via Digitalmars-d-learn
On Sunday, 26 March 2017 at 11:46:39 UTC, Jolly James wrote: On Sunday, 26 March 2017 at 11:35:00 UTC, Jolly James wrote: [...] Found out something: You cannot catch any exception thrown in the listen()-method in general. ■ Original code: [...] ■ Modified one: [...] ■ Not working

Re: Howto catch SocketOSException?

2017-03-25 Thread bauss via Digitalmars-d-learn
On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote: How do you catch an std.socket.SocketOSException? The following does not work, as the exception occurs anyway and leads to a crash: import ae.net.asockets; void main(string[] args) { TcpServer tcp = new TcpServer();

Re: union.sizeof

2017-03-25 Thread bauss via Digitalmars-d-learn
On Saturday, 25 March 2017 at 23:36:07 UTC, kinke wrote: On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote: zabruk70 wrote: [...] `align(1) union Union1` will do the trick. what you did is members packing. but the union itself is padded to integer size too. i.e. internal `align`

Re: questions about dub

2017-03-21 Thread bauss via Digitalmars-d-learn
On Tuesday, 21 March 2017 at 21:01:31 UTC, thorstein wrote: Hi, I have questions regarding the usage of 'dub'. I'm learning D under Win7. I have installed VisualD for the community edition of Visual Studio and got some file i/o working. Next I would like to continue with the mir-tools for

Re: How to get inner most nested struct

2017-03-16 Thread bauss via Digitalmars-d-learn
On Friday, 17 March 2017 at 01:52:20 UTC, Hussien wrote: On Friday, 17 March 2017 at 01:19:54 UTC, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 00:34:22 UTC, Hussien wrote: Anyway to do this? I don't think you can, the inner anonymous structs are just to organize the members and group

Re: Is there a more elegant way to do this?

2017-03-11 Thread bauss via Digitalmars-d-learn
On Sunday, 12 March 2017 at 05:13:41 UTC, bauss wrote: I was wondering if there's a more elegant way to do something like this? [...] I saw one improvement to it which would be BitSize!ChildType instead of taking parent type's bit size divided by two. Also value = ((highValue << 16 |

Is there a more elegant way to do this?

2017-03-11 Thread bauss via Digitalmars-d-learn
I was wondering if there's a more elegant way to do something like this? template BitSize(T) { enum BitSize = T.sizeof * 8; } struct Data(ParentType,ChildType) { @property { ChildType low() { return cast(ChildType)value; } void low(ChildType

Re: TLS

2017-03-10 Thread bauss via Digitalmars-d-learn
On Friday, 10 March 2017 at 07:33:44 UTC, M-exe wrote: On Friday, 10 March 2017 at 07:17:22 UTC, rikki cattermole wrote: D does not support Windows XP. If you absolutely require it, you will have to contact Walter about support. Let me care about it ;) I just need help with the TLS :) Mark

Re: Building a project with CMAKE

2017-03-02 Thread bauss via Digitalmars-d-learn
On Thursday, 2 March 2017 at 12:42:00 UTC, Russel Winder wrote: On Tue, 2017-02-28 at 17:09 +, berni via Digitalmars-d-learn wrote: [...] I do not have an immediate answer, but… CLion requires CMake, with CMake-D in a fit state we could use CLion with D – albeit very rough and ready

Re: Mixing libraries

2017-03-01 Thread bauss via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 20:08:25 UTC, Jordan Wilson wrote: Hello, Been trying to learn the Simple Fast Multimedia Library (SFML) using the Derelict bindings, and noticed some functionality is offered by both SFML and the std library (for example, sfClock and sfMutex). Is there a

Re: A bug?

2017-02-17 Thread bauss via Digitalmars-d-learn
On Wednesday, 15 February 2017 at 19:56:31 UTC, berni wrote: On Wednesday, 15 February 2017 at 16:11:36 UTC, drug wrote: No, you recursively call main() and get segfault (due to stack overflow) as expected I thought, that an stack overflow leeds to an exception. But that's not true, as I now

Re: std.system reports win32 when running OS X

2017-02-02 Thread Bauss via Digitalmars-d-learn
On Thursday, 2 February 2017 at 08:42:44 UTC, Andrea Fontana wrote: On Wednesday, 1 February 2017 at 21:43:09 UTC, Ali Çehreli wrote: That's a local variable that you've defined. Since OS.init happens to be OS.win32, that's what you get. :) Maybe it should be "unknown" or "undefined" :)

Re: Compile to C?

2017-01-23 Thread Bauss via Digitalmars-d-learn
On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote: Hi friends, Is there a way to "compile" d code to C, similar to what nim does? That would be cool for greater portability. Nim is able to, because Nim doesn't really compile. The Nim compiler just translates Nim code to C code

Re: Auto recursive function

2017-01-12 Thread Bauss via Digitalmars-d-learn
On Thursday, 12 January 2017 at 00:30:33 UTC, Ignacious wrote: On Wednesday, 11 January 2017 at 19:23:10 UTC, Razvan Nitu wrote: [...] If you change the return type to a void* your code basically works. void* makeMultidimensionalArray(T, Allocator)(auto ref Allocator alloc, size_t[]

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

2017-01-02 Thread bauss via Digitalmars-d-learn
On Monday, 2 January 2017 at 18:56:40 UTC, Mike Bierlee wrote: When compiling the following code with DMD 2.072.2: class LeClass { import std.stdio; } void main() { foreach (memberName; __traits(allMembers, LeClass)) { pragma(msg, memberName); } } The

<    1   2   3   4   5   6   >