Re: bool passed by ref, safe or not ?

2024-06-04 Thread Olivier Pisano via Digitalmars-d-learn
On Wednesday, 5 June 2024 at 05:15:42 UTC, Olivier Pisano wrote: This is technically not a memory corruption, because as bool.sizeof < int.sizeof, you just write the low order byte of an int you allocated on the stack. It was not an int, it was a ushort. Anyway, what I wrote still applies.

Re: bool passed by ref, safe or not ?

2024-06-04 Thread Olivier Pisano via Digitalmars-d-learn
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote: question in the header, code in the body, execute on a X86 or X86_64 CPU I understand that the notion of `bool` doesn't exist on X86, hence what will be used is rather an instruction that write on the lower 8 bits, but with a 7 bits

Re: How best to implement items and weapons in my RPG. Nested classes? Delegates?

2024-04-04 Thread Olivier Pisano via Digitalmars-d-learn
Hi, You should have a look at the decorator design pattern, it reduces the amount of classes to implement if you need to combine different effects such as elemental damage to your weapons (e.g. if you want flame arrows). https://en.wikipedia.org/wiki/Decorator_pattern

Re: length's type.

2024-01-28 Thread Olivier Pisano via Digitalmars-d-learn
On Sunday, 28 January 2024 at 08:55:54 UTC, zjh wrote: On Sunday, 28 January 2024 at 06:34:13 UTC, Siarhei Siamashka wrote: The explicit conversion `.length.to!int` has an extra benefit I rarely use numbers over one million. But do I have to consider numbers over `4 billion` every day?

Re: Is sizeof() available in D language?

2023-09-04 Thread Olivier Pisano via Digitalmars-d-learn
On Monday, 4 September 2023 at 09:41:54 UTC, BoQsc wrote: I've seen everyone using **datatype**`.sizeof` property. https://dlang.org/spec/property.html#sizeof It's great, but I wonder if it differ in any way from the standard C function `sizeof()`. Technically speaking, in C, sizeof is not

Re: Evolving the D Language

2023-07-08 Thread Olivier Pisano via Digitalmars-d-announce
On Friday, 7 July 2023 at 10:45:33 UTC, Guillaume Piolat wrote: On Friday, 7 July 2023 at 09:35:14 UTC, Paolo Invernizzi wrote: I respectfully disagree, and prefer to keep going on with the current deprecation and cleanup policy: Scott Meyers' DConf 2014 keynote all the way down. +1 I've

Connecting to D-Bus signals

2022-10-04 Thread Olivier Pisano via Digitalmars-d-learn
Hi, I am currently trying to connect to a signal on UDisks2 to be notified whenever the user plugs a USB drive on the system, but my method never gets called. Here is my code : import ddbus; import ddbus.c_lib; import std.stdio; final class UsbDevice { void

Re: How to get rid of "nothrow" ?

2020-05-17 Thread Olivier Pisano via Digitalmars-d-learn
On Sunday, 17 May 2020 at 09:27:40 UTC, Vinod K Chandran wrote: Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my window on screen. But for handling messages, i planned to write something like message crackers in c++. But since, my WndProc

Re: XMM Intrinsics

2020-05-09 Thread Olivier Pisano via Digitalmars-d-learn
On Friday, 8 May 2020 at 12:38:51 UTC, Marcio Martins wrote: Hi, I am building a CRC32C implementation using SSE for D, because I couldn't find any readily available :[ Here is mine: https://github.com/opisano/crc32c/blob/master/crc32c.d

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread Olivier Pisano via Digitalmars-d-learn
On Monday, 4 May 2020 at 09:20:06 UTC, Ali Çehreli wrote: On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at 16:55:36 UTC, Robert M. Münch wrote: > I think you want to use scope rather than auto which will put the class > on the stack and call its destructor: >

Re: How do I extract and convert datatypes from ResultRange

2019-08-26 Thread Olivier Pisano via Digitalmars-d-learn
On Monday, 26 August 2019 at 13:49:21 UTC, Anders S wrote: Hi guys, I'm trying to read a post of different datatypes from MariaDB table into another message and pass it on into a FIFO pipe to an other application. My code : string sql = "SELECT * FROM guirequest WHERE read_request =

Re: How to ensure string compatibility In D?

2019-01-22 Thread Olivier Pisano via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 13:55:30 UTC, FrankLike wrote: Hi,everyone, In C++, _T can guarantee that when converting from ascii encoding type to unicode encoding type, the program does not need to be modified. What do I need to do in D? Thanks. Hi, _T is not relevant to C++, but to

Re: [OT] "I like writing in D" - Hans Zimmer

2018-08-26 Thread Olivier Pisano via Digitalmars-d
On Wednesday, 22 August 2018 at 22:51:58 UTC, Piotrek wrote: You may already know that from youtube. It seems D starts getting traction even among musicians: https://www.youtube.com/watch?v=yCX1Ze3OcKo=youtu.be=64 That really put a smile on my face :D And it would be a nice example of a D

Re: Article: Running D without its runtime

2016-11-10 Thread Olivier Pisano via Digitalmars-d-announce
On Thursday, 10 November 2016 at 11:11:17 UTC, Guillaume Piolat wrote: On Thursday, 10 November 2016 at 06:52:12 UTC, Olivier Pisano wrote: I cannot read your website on Firefox 45 (no text is displayed). It works on chromium anyway. I develop it on Firefox. What is your OS? I am on Debian

Re: Article: Running D without its runtime

2016-11-09 Thread Olivier Pisano via Digitalmars-d-announce
I cannot read your website on Firefox 45 (no text is displayed). It works on chromium anyway.

Re: Recommended coding convention for combining unix and windows code ?

2016-06-08 Thread Olivier Pisano via Digitalmars-d-learn
Hi, I personally separate OS-specific implementations in modules with the same name, in different directories. From the filesystem perspective: widget.d linux/widgetimpl.d windows/widgetimpl.d From the code perspective, the *impl modules would present homonymic types with the same public

Re: D equivalent of C++ bind ?

2016-05-10 Thread Olivier Pisano via Digitalmars-d-learn
Salut Christophe, Did you have a look at https://dlang.org/phobos/std_functional.html#partial ?

Re: How about use Gc as a big memory pool?

2016-04-07 Thread Olivier Pisano via Digitalmars-d-learn
On Friday, 8 April 2016 at 03:27:04 UTC, Dsby wrote: when the soft start, call GC.disable(). use "new " create a class , struct or a array. and use destory(T/void *) to call the ~this(), then GC.free to free the memory, and use RAII in class or Struct. And user the Timer, or in some where to

Re: nogc Array

2016-01-26 Thread Olivier Pisano via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 05:53:29 UTC, Igor wrote: On Tuesday, 26 January 2016 at 04:38:13 UTC, Adam D. Ruppe wrote: On Tuesday, 26 January 2016 at 04:31:07 UTC, Igor wrote: then std.algorithm.find!("a.myInt == b")(classes, 3) Try std.algorithm.find!("a.myInt == b")(classes[], 3)

Re: static array crashes my program

2015-12-05 Thread Olivier Pisano via Digitalmars-d-learn
On Saturday, 5 December 2015 at 09:49:06 UTC, ref2401 wrote: I want to create a static array large enough to store 1MB of float values. What am I doing wrong? Here is a sample code with notes: void main(string[] args) { enum size_t COUNT = 1024 * 512 / float.sizeof; // works OK :)

Re: DConf keynote speaker ideas

2015-11-17 Thread Olivier Pisano via Digitalmars-d
On Tuesday, 17 November 2015 at 18:47:58 UTC, Andrei Alexandrescu wrote: I'm thinking of inviting a notable industry luminary to deliver a conference keynote. Please reply to this with ideas! -- Andrei Erik Meijer?

Re: `clear`ing a dynamic array

2015-10-25 Thread Olivier Pisano via Digitalmars-d-learn
On Sunday, 25 October 2015 at 04:04:29 UTC, Shriramana Sharma wrote: rsw0x wrote: use std.container.array Thanks all for all the recommendations. When would one use std.array.appender with a built-in array vs std.container.array.Array? What are the pros and cons on either side? Appender

Re: Walter and I talk about D in Romania

2015-10-04 Thread Olivier Pisano via Digitalmars-d-announce
On Saturday, 3 October 2015 at 23:05:41 UTC, deadalnix wrote: On Saturday, 3 October 2015 at 12:29:17 UTC, Marco Leise wrote: That's a lot of people. You must be some kind of programming national hero in Romania. Good luck and watch out for those C++ moroi in the audience! Time to get a Dman

Re: Reading and converting binary file 2 bits at a time

2015-08-27 Thread Olivier Pisano via Digitalmars-d-learn
On Thursday, 27 August 2015 at 09:38:52 UTC, Andrew Brown wrote: That's lovely, thank you. One quick question, the length of the file is not a multiple of the length of ubyte, but the cast still seems to work. Do you know how it converts a truncated final section? Thanks again Andrew

Re: Arrays of structs

2015-08-27 Thread Olivier Pisano via Digitalmars-d-learn
On Thursday, 27 August 2015 at 10:49:02 UTC, John Burton wrote: To be honest I'm finding it very hard to find the right idioms in D for safe and efficient programming when I'm so used to C++ / RAII everywhere. I'll adapt though :P This is true for every new language you learn. You first

Re: Programming in D paper book is available for purchase

2015-08-20 Thread Olivier Pisano via Digitalmars-d-announce
On Wednesday, 19 August 2015 at 00:57:32 UTC, Ali Çehreli wrote: I am very happy! :) It will be available on many other distribution channels like Amazon in a few days as well but the following is the link that pays me the most royalty: https://www.createspace.com/5618128 This revision

Re: Difference between __gshared and shared.

2015-07-08 Thread Olivier Pisano via Digitalmars-d
On Wednesday, 8 July 2015 at 09:20:58 UTC, wobbles wrote: After reading the recent Lessons Learned article [1], and reading a few comments on the thread, there was a mention of using __gshared over shared. What exactly is the difference here? Are they 2 keywords to do the same thing, or are

Re: [NEEDING HELP] Translation of Ali Cehreli's book in French

2015-03-14 Thread Olivier Pisano via Digitalmars-d
On Saturday, 14 March 2015 at 08:38:06 UTC, Raphaël Jakse wrote: Le 13/03/2015 16:45, Olivier Pisano a écrit : What is the next chapter to need translation ? It should be const ref Parameters and const Member Functions but Scroph might want to translate it as it seems to be the following of

Re: [NEEDING HELP] Translation of Ali Cehreli's book in French

2015-03-13 Thread Olivier Pisano via Digitalmars-d
What is the next chapter to need translation ? 

Re: [NEEDING HELP] Translation of Ali Cehreli's book in French

2015-03-02 Thread Olivier Pisano via Digitalmars-d
The chapter on function overloading is translated. If it is OK with you, I acquire the mutex on const ref Parameters and const Member Functions, then :o)

Re: [NEEDING HELP] Translation of Ali Cehreli's book in French

2015-02-22 Thread Olivier Pisano via Digitalmars-d
I did send you a first draft of the variable number of parameters chapter on Friday, on your gmail address. Did you get it ? 

Re: [NEEDING HELP] Translation of Ali Cehreli's book in French

2015-02-22 Thread Olivier Pisano via Digitalmars-d
On Sunday, 22 February 2015 at 22:27:42 UTC, Raphaël Jakse wrote: Le 22/02/2015 14:00, Olivier Pisano a écrit : I did send you a first draft of the variable number of parameters chapter on Friday, on your gmail address. Did you get it ? Yes, I thought I answered to your mail. Sorry if I

Re: D plan to do RAII(Resource Acquisition Is Initialization)?

2015-02-21 Thread Olivier Pisano via Digitalmars-d
On Saturday, 21 February 2015 at 10:06:26 UTC, FrankLike wrote: RAII(Resource Acquisition Is Initialization) is a good thing,will D plan to do it? It's already here : import std.stdio; struct Test { ~this() { writeln(RAII); } } void main() { Test t; // prints RAII when goes out of

Re: [NEEDING HELP] Translation of Ali Cehreli's book in French

2015-02-18 Thread Olivier Pisano via Digitalmars-d
On Tuesday, 17 February 2015 at 22:46:01 UTC, Raphaël Jakse wrote: To begin the translation of a chapter, I suggest you tell it here so two people are not translating the same chapter at the same time. Ok, I am gonna start with the Variable number of parameters chapter, then. I am thinking

Re: [NEEDING HELP] Translation of Ali Cehreli's book in French

2015-02-17 Thread Olivier Pisano via Digitalmars-d
On Tuesday, 17 February 2015 at 17:29:15 UTC, Raphaël Jakse wrote: Is anybody interested? Don't hesitate to send me an email if you are willing to get involved, even for the smallest task. There are no small tasks when a work is to get completed. I will tell you how to help. I suppose I

Re: RFC: reference counted Throwable

2014-09-20 Thread Olivier Pisano via Digitalmars-d
On Saturday, 20 September 2014 at 06:28:11 UTC, Paulo Pinto wrote: This is one of the reasons why the Objective-C GC failed. Mixing Frameworks compiled with both modes never worked properly. -- Paulo Yes this was a huge failure to take into account. Linking code where Throwable inherits

Re: Concatenates int

2014-07-10 Thread Olivier Pisano via Digitalmars-d-learn
Hello, I may have not understood what you actually want to do, but aren't std.bitmanip.peek or std.bitmanip.read what you are looking for ? http://dlang.org/phobos/std_bitmanip.html#.peek

Re: What exactly module in D means?

2014-07-05 Thread Olivier Pisano via Digitalmars-d-learn
No, import is different from include. It does not stupidly copy and paste its content but tells the compiler to take the module into account for name resolution. The result may seem similar, but is much more efficient. A D module is also a unit of encapsulation (a private declaration in a module

Re: Equivalent of C++ std::function

2014-06-24 Thread Olivier Pisano via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 03:33:15 UTC, Yuushi wrote: Thanks a ton - I guess I need to do a fair bit more reading about alias. In this case, alias acts as typedef in C++. What is important here is the function pointers/delegates syntax.

Re: Adam D. Ruppe's D Cookbook now available!

2014-05-28 Thread Olivier Pisano via Digitalmars-d-announce
I have just ordered mine. I can't wait to get it ! 

Re: Does D support plugins with dll written in D ?

2014-05-27 Thread Olivier Pisano via Digitalmars-d
Hello :) AFAIK, Higher-level library support is planned for next release (v2.066) [1]. Meanwhile, you'll have to rely on your own exported factory functions to create objects instead of Object.factory(). 1 : http://wiki.dlang.org/Agenda#high-level_shared_library_support