Re: byte array to string

2021-02-24 Thread Mike via Digitalmars-d-learn
On Thursday, 25 February 2021 at 06:58:51 UTC, FeepingCreature wrote: On Thursday, 25 February 2021 at 06:57:57 UTC, FeepingCreature wrote: On Thursday, 25 February 2021 at 06:47:11 UTC, Mike wrote: hi all, If i have an array: byte[3] = [1,2,3]; How to get string "123" from it? Thanks in

byte array to string

2021-02-24 Thread Mike via Digitalmars-d-learn
hi all, If i have an array: byte[3] = [1,2,3]; How to get string "123" from it? Thanks in advance.

thread ring

2020-09-12 Thread Mike via Digitalmars-d-learn
hi all, Before more complex problem I've implement thread ring how I feel it as warmup fun. Comments and objections are very welcome. --- import std.stdio; import std.concurrency; void worker(int i) { Tid neib; int N; bool stop = false; receive((Tid message) { neib =

Proper desctructor for an class containing dynamic array of objects

2019-06-13 Thread Mike via Digitalmars-d-learn
Hi, my name is Mike and I'm new to D (coming from a Javabackground) and for fun I'm trying to learn D now. I created a simple class class Block { int a, b; this() {} } And now I have a dynamic array of objects of this class in another class: class Foo { Block[] array =

Re: Create class on stack

2017-08-07 Thread Mike via Digitalmars-d-learn
On Monday, 7 August 2017 at 13:42:33 UTC, Moritz Maxeiner wrote: You can still create a (scope) class on the stack, escape a reference to it using `move` and use it afterwards, all within the rules of @safe, so I'm not convinced that the reason for deprecating scoped classes is gone yet.

Re: Create class on stack

2017-08-07 Thread Mike via Digitalmars-d-learn
On Sunday, 6 August 2017 at 15:47:43 UTC, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though. [1]

Re: Is std.xml seriously broken, or is it me?

2017-07-29 Thread Mike via Digitalmars-d-learn
On Sunday, 30 July 2017 at 02:58:09 UTC, Mike wrote: import std.xml; import std.stdio; void main() { auto parser = new DocumentParser("encoding=\"utf-8\"?>"); parser.onStartTag["device"] = (ElementParser parser) { writeln("device"); }; parser.parse(); }

Is std.xml seriously broken, or is it me?

2017-07-29 Thread Mike via Digitalmars-d-learn
I'm trying to use std.xml, and I can't get it to work. I tried the simplest program I could think of: import std.xml; import std.stdio; void main() { auto parser = new DocumentParser("encoding=\"utf-8\"?>"); parser.onStartTag["device"] = (ElementParser parser) {

Re: BetterC and TypeInfo Question

2017-06-22 Thread Mike via Digitalmars-d-learn
On Friday, 23 June 2017 at 02:14:08 UTC, Adam D. Ruppe wrote: Yes, it is necessary, but how much? Can we do it with implicitly generated library code? I'm pretty sure the answer is "not much" and "yes", but I still need to ponder the details. I think the typeinfo for a class good enough for

Re: how to allocate class without gc?

2016-01-26 Thread Mike via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: Is there any examples that shows how to properly allocate an object of a class type with the new allocators and then release it when desired? There are a number of different patterns discussed and illustrated with examples at

Re: std.experimental.logger

2016-01-04 Thread Mike via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 02:44:48 UTC, sanjayss wrote: I'm doing the following: import std.experimental.logger; int main(string[] args) { sharedLog = new FileLogger("logfile.log"); log("Test log 1"); log("Test log 2"); log("Test log 3"); } and I expected the logs to be seen in the

Re: std.experimental.logger

2016-01-04 Thread Mike via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 02:59:04 UTC, sanjayss wrote: On Tuesday, 5 January 2016 at 02:49:01 UTC, Mike wrote: [...] Thanks, that works. But the docs are confusing -- it gives the impression that "sharedLog" is something associated with the default logger -- so I would expect the above

Re: What does the -betterC switch in dmd do?

2015-11-16 Thread Mike via Digitalmars-d-learn
On Sunday, 15 November 2015 at 15:34:19 UTC, Jacob Carlborg wrote: I'm pretty sure that the only things that are excluded are module info and type info. It's still possible to use "new" and all the array features that requires support in the runtime (slicing, concatenation, appending and so

Re: RAII and Deterministic Destruction

2015-08-25 Thread Mike via Digitalmars-d-learn
On Tuesday, 25 August 2015 at 22:35:57 UTC, Jim Hewes wrote: Although C++ can be ugly, one reason I keep going back to it rather then commit more time to reference-based languages like C# is because I like deterministic destruction so much. My question is whether D can REALLY handle this or

Re: unusual bare metal target: Amazon Dash

2015-08-20 Thread Mike via Digitalmars-d-learn
On Tuesday, 18 August 2015 at 01:32:13 UTC, Laeeth Isharc wrote: I don't know whether D can run on one, but from a quick look perhaps feasible. Running D on something like this (perhaps it's underpowered, but looked to have similar spec to what people had been doing with related ARM cortex

Re: What is the exact meaning of 'nothrow'?

2015-06-10 Thread Mike via Digitalmars-d-learn
On Thursday, 11 June 2015 at 00:27:36 UTC, Ali Çehreli wrote: Note: Remember that it is not recommended to catch Error nor its base class Throwable. What I mean by any exception here is any exception that is defined under the Exception hierarchy. A nothrow function can still emit exceptions

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
FYI, I didn't realize this (but just figured it out), C main *used* to be in druntime, but it's now generated by the compiler. See here: https://github.com/D-Programming-Language/dmd/blob/master/src/mars.c#L236 True. But it is compiler-dependent. GDC actually still defines C main in the

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
Could you explain what mean C main inside the runtime. I thought that is only one main is possible. And why it's named *С* main D is not C-translated language. Same question is about _Dmain -- what is it? If I will call this() before main? What it will be? Will it run before main?

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
On Saturday, 23 May 2015 at 10:57:22 UTC, Suliman wrote: Every D program is started as if it were a C program. Why is so necessary? It's not actually necessary. You could implement the `_start` function in your D program. Here's a D program without any C runtime, D runtime, or main.

Re: Necessity of D Library (and/or Core Library)

2015-05-23 Thread Mike via Digitalmars-d-learn
On Saturday, 23 May 2015 at 06:35:50 UTC, Anthony Monterrosa wrote: Does D require the standard library to function? Or to be more direct, does D as a language need its library, or core library, to function correctly? There are two main libraries in D: The D Runtime, and the standard

Re: how does 'shared' affect member variables?

2015-05-09 Thread Mike via Digitalmars-d-learn
On Saturday, 9 May 2015 at 20:17:59 UTC, bitwise wrote: On Sat, 09 May 2015 15:38:05 -0400, Mike n...@none.com wrote: On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful.

Re: how does 'shared' affect member variables?

2015-05-09 Thread Mike via Digitalmars-d-learn
On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful. Here are a few interesting links: Iain Buclaw (lead developer for GDC) with his interpretation:

Re: Startup files for STM32F4xx

2015-04-25 Thread Mike via Digitalmars-d-learn
On Saturday, 25 April 2015 at 16:32:50 UTC, Timo Sintonen wrote: On Saturday, 25 April 2015 at 11:56:55 UTC, Martin Nowak wrote: I have not yet needed anything from libc/phobos in my programs. I think there's a few gems that can be cherry-picked out of Phobos, especially for metaprogramming:

Re: Startup files for STM32F4xx

2015-04-25 Thread Mike via Digitalmars-d-learn
On Saturday, 25 April 2015 at 19:33:05 UTC, Johannes Pfau wrote: volatileLoad is not in gdc yet. I've written the code some months ago but I need to update it and then it needs to be reviewed. It's officially in 2.067.0 for anyone who's wondering. Volatile!T:

Re: Startup files for STM32F4xx

2015-04-24 Thread Mike via Digitalmars-d-learn
On Saturday, 25 April 2015 at 00:33:26 UTC, Steven Schveighoffer wrote: http://www.digikey.com/product-search/en?x=0y=0lang=ensite=uskeywords=stm32f429+discovery This is super tempting @ $24. As someone who is not used to tinkering with raw hardware, how does one power this thing? I've

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to change the VectorFunc to be a real function pointer, rather than a void* ? I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc =

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to change the VectorFunc to be a real function pointer, rather than a void* ? I did something along these lines (modified to match your

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 16:10:53 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: -I actually added @attribute(naked) to my defaultResetHandler yesterday, as I wanted to get rid of the prologue;

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 15:44:00 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc = void function(); @attribute(weak) @attribute(alias,

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 17:45:01 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 15:53:37 UTC, Jens Bauer wrote: [snip] I find it strange that calling an empty function outside the source file will cause that huge difference. -But of course, there's a logic explanation somewhere. ;)

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Thursday, 9 April 2015 at 00:37:32 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: I actually added that out of necessity, not optimization. Id I use the STM32, and reset the MCU, the CCRAM is disabled by default. Since my stack is in CCRAM, I need to first

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: On Wednesday, 8 April 2015 at 16:10:53 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: -I actually added @attribute(naked) to my

static alias this

2015-02-07 Thread Mike via Digitalmars-d-learn
Consider this simple example A)- struct StaticRegister { static private uint _value; @property static uint value() { return _value; } @property static void value(uint v) { _value = v; } } void main(string[] s) { StaticRegister = 1;

What is RTInfo?

2015-01-29 Thread Mike via Digitalmars-d-learn
object.d [1] says it's infomation for the precise GC (which I thought wasn't implemented yet). It just seems to return a void*. But, searching the source code, it doesn't seem to be set by anything anywhere. So, what is RTInfo and what is its purpose. And how is it different from

Struggling with shared objects

2015-01-17 Thread Mike via Digitalmars-d-learn
Hey, all. I have just started using D and I'm really loving it, but I have been caught on a problem. I am trying to share my Client class to a new thread, and after a bit of struggling: I finally got the code to compile! Now I am having a new problem: the moment I call client.receive(buf) I get

Re: Struggling with shared objects

2015-01-17 Thread Mike via Digitalmars-d-learn
Ha, I am so stupid! I forgot to call the socket member before receive! Thank you for the help. I have also removed the pointers. I am now getting this: C:\Users\Michael\Documents\Projects\StompBroker\StompBrokerdmd main.d main.d(11): Error: None of the overloads of 'receive' are callable

Re: Struggling with shared objects

2015-01-17 Thread Mike via Digitalmars-d-learn
On Saturday, 17 January 2015 at 21:12:34 UTC, Vlad Levenfeld wrote: That's real weird. In D:\D\dmd2\src\phobos\std\concurrency.d(13,13) 13,13 isn't a line number and static assertions should go off during compilation, not runtime. It is during compilation. When I run dmd myself, I get this:

Re: Struggling with shared objects

2015-01-17 Thread Mike via Digitalmars-d-learn
Oh, I said the moment I call I should have reworded that. I meant that the moment I add that line to the code, I get the error. Sorry!

Re: Struggling with shared objects

2015-01-17 Thread Mike via Digitalmars-d-learn
Thank you so much! I got it all working now. You're definitely right, that is still easier than C++.

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread Mike via Digitalmars-d-learn
On Monday, 12 January 2015 at 19:29:54 UTC, jmh530 wrote: I'm new to D. I have some modest knowledge of C++, but am more familiar with scripting languages (Matlab, Python, R). D seems so much easier than C++ in a lot of ways (and I just learned about rdmd today, which is pretty cool). I am

druntime vararg implementation

2014-11-05 Thread Mike via Digitalmars-d-learn
Greetings, In core.varar. (https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), why is the X86 implementation singled out and written in D rather than leveraging the standard c library implementation like the others? Mike

Re: druntime vararg implementation

2014-11-05 Thread Mike via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 14:24:00 UTC, Sean Kelly wrote: On Wednesday, 5 November 2014 at 09:45:50 UTC, Mike wrote: Greetings, In core.varar. (https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), why is the X86 implementation singled out and written in D

Re: Problem with spec doc?

2014-11-01 Thread Mike via Digitalmars-d-learn
On Saturday, 1 November 2014 at 15:02:44 UTC, Shriramana Sharma via Digitalmars-d-learn wrote: Hello. I already posted this via the forum interface: http://forum.dlang.org/thread/yqhwwpskwmkdefarj...@forum.dlang.org But for whatever reason I didn't get any replies so I worry if it actually

Re: Problem with spec doc?

2014-11-01 Thread Mike via Digitalmars-d-learn
On Saturday, 1 November 2014 at 15:48:27 UTC, Shriramana Sharma via Digitalmars-d-learn wrote: Thank you very much. But this is curious -- isn't Andrei himself able to directly commit or answer that pull request?!! All pull requests need to be peer reviewed, even those submitted by

forum.dlang.org open source?

2014-10-26 Thread Mike via Digitalmars-d-learn
Does forum.dlang.org have an open source repository somewhere that we can contribute pull requests to, or are bug reports to recommended procedure. I see that the left navigation menu needs updating, and I think we can wordsmith the forum descriptions a little to make it clearer where to

Re: forum.dlang.org open source?

2014-10-26 Thread Mike via Digitalmars-d-learn
On Monday, 27 October 2014 at 02:24:04 UTC, MachineCode wrote: On Sunday, 26 October 2014 at 23:57:41 UTC, Mike wrote: Are you going to use HTML in the posts? because neither Walter and probably forum maintainer wants to use it. I don't plan on adding HTML to the posts. And you don't need

Re: How to build dlang.org dd files

2014-08-31 Thread Mike via Digitalmars-d-learn
On Sunday, 31 August 2014 at 05:41:58 UTC, Mike wrote: I've been trying to update some documentation on dlang.org. The instructions at https://github.com/D-Programming-Language/dlang.org/blob/master/CONTRIBUTING.md say I should be able to do make -f posix.make file.html This doesn't seem

How to build dlang.org dd files

2014-08-30 Thread Mike via Digitalmars-d-learn
I've been trying to update some documentation on dlang.org. The instructions at https://github.com/D-Programming-Language/dlang.org/blob/master/CONTRIBUTING.md say I should be able to do make -f posix.make file.html This doesn't seem to work, as I get no rule t omake target 'file.html'.

Re: clear works better than it ought to considered i never defined it

2014-07-28 Thread Mike via Digitalmars-d-learn
On Monday, 28 July 2014 at 06:27:44 UTC, Vlad Levenfeld wrote: A weird thing happened: I was building a dictionary struct which contains a custom array of values and a differently-typed custom array of keys. Both of them implicitly define clear by aliasing a backing array. The dictionary

Contributing to D language

2014-06-23 Thread Mike via Digitalmars-d-learn
I wish I could help with the development of D (either the compiler or std library). Is there a TODO list kept somewhere? Neither Phobos nor DMD have an `issues` page on Github.. I found this http://wiki.dlang.org/Review_Queue but it's kind of short. Best regards, Mike

Re: Working on a library: request for code review

2014-06-20 Thread Mike via Digitalmars-d-learn
Do you think it's ready for a v0.1 release? It be willing to add it to dub if it passes general D coding stardards. Once again, thanks for feedback and vast improvements of the code. Best, Mike

Re: Working on a library: request for code review

2014-06-19 Thread Mike via Digitalmars-d-learn
Once again thanks for the feedback. The RLE rewrite using std is impressive! I will use it today or tomorrow, great stuff.

Re: Working on a library: request for code review

2014-06-17 Thread Mike via Digitalmars-d-learn
Thanks, will work on fixes tonight. The current method will not detect an error when the image type is not mapped but a color map is present. At least I assume that is not a valid TGA file? A non-mapped image may contain a color map ;-0 it's simply discarded. As per your ideas return

Re: Working on a library: request for code review

2014-06-16 Thread Mike via Digitalmars-d-learn
I have refactored the code as recommended. I have also modified the not-yet-reviewed writers part to take advantage of the same approach (preallocated static-sized buffer) rather than allocate slices in loops. Hoping to hear something from you guys! Best, Mike

Re: Working on a library: request for code review

2014-06-15 Thread Mike via Digitalmars-d-learn
On Friday, 13 June 2014 at 21:09:23 UTC, Mike Wey wrote: On 06/12/2014 09:30 PM, Rene Zwanenburg wrote: I remember a function which does something like only only + canFind on one go. It would look something like header.colorMapDepth.among(16, 32); but I can't find it right now.. Maybe it was

Re: Working on a library: request for code review

2014-06-13 Thread Mike via Digitalmars-d-learn
On Thursday, 12 June 2014 at 19:30:06 UTC, Rene Zwanenburg wrote: I need to go. Please don't mind any typo's and untested code ;). Didn't take a look at writers yet, readers and util need some more scrutiny, but the main theme is: eliminate unnecessary temporary GC allocations. Thank you for

Re: Working on a library: request for code review

2014-06-12 Thread Mike via Digitalmars-d-learn
On Thursday, 12 June 2014 at 00:20:28 UTC, cal wrote: Might it be worth stitching things together into a proper image processing package? Well I started working on TGA because I was disappointed that no image abstraction is present in Phobos. Go has some imaging APIs and I think D would

Re: Working on a library: request for code review

2014-06-12 Thread Mike via Digitalmars-d-learn
I can shed some light on my, beginners, point of view and the rationale behind this tiny library. I want to create a bar/matrix-code generator (QR, DataMatrix etc.). I really like graphics-related subjects and I thought this would be a good start in D. Coming from Java island and having

Working on a library: request for code review

2014-06-11 Thread Mike via Digitalmars-d-learn
Hello. I am new to D and I must admit I really like the language. In my opinion it takes the best from C++ and, say, Python and combines it really elegantly. Great work! I am currently working on my first library in D - related to TARGA image format. Here's the link to the repo:

Multi-file project problem with Visual D

2014-06-01 Thread Mike via Digitalmars-d-learn
I've created a small Windows based program using a win32 library I found online. That part is working just fine. I've also created a second file (called util.d) and within it defined a class called MyData (with a member function called Read()). Within my main program I instantiate and try

Re: Multi-file project problem with Visual D

2014-06-01 Thread Mike via Digitalmars-d-learn
On Monday, 2 June 2014 at 01:01:22 UTC, Mike wrote: I've created a small Windows based program using a win32 library I found online. That part is working just fine. I've also created a second file (called util.d) and within it defined a class called MyData (with a member function called