setjmp / longjmp

2015-04-25 Thread Cassio Butrico via Digitalmars-d-learn
Hello everyone , first congratulations for the wonderful forum , I wish someone could help me , I am writing a small basic interpreter in D and I am with some difficulties. estoutentando manupular the setjmp / longjmp buffers , but the error , I use windows 7 and the dmd 2067 , will be whose

Re: Startup files for STM32F4xx

2015-04-25 Thread Timo Sintonen via Digitalmars-d-learn
On Saturday, 25 April 2015 at 17:04:18 UTC, Jens Bauer wrote: I think volatileLoad and volatileStore are intended for this (please correct me if my understanding is wrong). Yes. Actually I am not sure whether they already exist in gdc or not. Try to write for example regs.cmdr |= 0x20 with

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 17:58:59 UTC, Timo Sintonen wrote: On Saturday, 25 April 2015 at 17:04:18 UTC, Jens Bauer wrote: I think volatileLoad and volatileStore are intended for this (please correct me if my understanding is wrong). Yes. Actually I am not sure whether they already exist

Private alias escaping -- is this a bug?

2015-04-25 Thread rcorre via Digitalmars-d-learn
I ran into this infuriatingly confusing situation just now: static assert(is(typeof(Parent.init.new Child) == Parent.Child)); // fine alias P = Parent; alias T = Parent.Child; static assert(is(typeof(P.init.new T) == T)); // nope! Wat??? After much confusion, I finally discovered this in

Re: Private alias escaping -- is this a bug?

2015-04-25 Thread Vlad Levenfeld via Digitalmars-d-learn
On Saturday, 25 April 2015 at 23:51:05 UTC, rcorre wrote: I ran into this infuriatingly confusing situation just now: static assert(is(typeof(Parent.init.new Child) == Parent.Child)); // fine alias P = Parent; alias T = Parent.Child; static assert(is(typeof(P.init.new T) == T)); // nope!

@disable assignment of [] literal?

2015-04-25 Thread Meta via Digitalmars-d-learn
Consider the following code: struct ArrayWrapper(T) { T t; this(T t) { assert(t !is null); } @disable this(typeof(null)); typeof(this) opAssign(T val) { assert(t !is null); this.t = val; return this; }

Re: Startup files for STM32F4xx

2015-04-25 Thread Johannes Pfau via Digitalmars-d-learn
Am Sat, 25 Apr 2015 11:38:45 + schrieb Martin Nowak c...@dawg.eu: On Saturday, 25 April 2015 at 05:07:04 UTC, Jens Bauer wrote: I hope to find a good way to use import for microcontroller libraries, so it'll be easy for everyone. I'm thinking about something like ... import

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer 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: You better dismiss the idea of using druntime/phobos. The minimum runtime I have made does fit in 64k rom/ 64k ram, which all STM32F4 devices have. With some work

Re: BigInt to binary

2015-04-25 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 25 April 2015 at 18:58:50 UTC, Marc Schütz wrote: BigInt only supports %d, %x, %X and %s: http://dlang.org/phobos/std_bigint.html#.BigInt.toString The missing %o and %b were probably an oversight, feel free to file an enhancement request or submit a PR. All right. I will file a

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 Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 16:28:24 UTC, Timo Sintonen wrote: My work is based on the feature that a shared variable is marked as volatile in gcc. This feature is buggy and should not be used in the future. I think volatileLoad and volatileStore are intended for this (please correct me if

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 11:50:19 UTC, Martin Nowak wrote: On Saturday, 25 April 2015 at 07:31:45 UTC, Jens Bauer wrote: Static constructors are possible if you strip down ModuleInfo (requires compiler hacking). You should care about that stuff last. It's way more important to make things

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-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 11:34:58 UTC, Martin Nowak wrote: You can very well abstract an SPI, just need to have an abstraction for pins. http://developer.mbed.org/handbook/SPI Considering all the problems involved, I will not be doing any abstraction. What I will provide, is a set of

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 17:11:22 UTC, Johannes Pfau wrote: Am Sat, 25 Apr 2015 11:38:45 + schrieb Martin Nowak c...@dawg.eu: On Saturday, 25 April 2015 at 05:07:04 UTC, Jens Bauer wrote: import mcu.stm32f439.all I think that belongs in the makefile/dub.json as -version=STM32F439.

Microcontroller startup file - supported devices wish-list

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
As I'm impressed with the interest in the startup-files I've made so far, I'd like to add support for more devices. In order to do so, I'd like to ask on this forum, which devices you would be interested in. Please list specific device names/numbers if possible, but device families are of

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:

Re: Startup files for STM32F4xx

2015-04-25 Thread Johannes Pfau via Digitalmars-d-learn
Am Sat, 25 Apr 2015 18:31:45 + schrieb Jens Bauer doc...@who.no: On Saturday, 25 April 2015 at 17:58:59 UTC, Timo Sintonen wrote: On Saturday, 25 April 2015 at 17:04:18 UTC, Jens Bauer wrote: I think volatileLoad and volatileStore are intended for this (please correct me if my

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 19:33:05 UTC, Johannes Pfau wrote: Am Sat, 25 Apr 2015 18:31:45 + schrieb Jens Bauer doc...@who.no: I don't want to start another volatile discussion, but to me it seems an attribute would not be a bad idea. -And for completeness... read-only, write-only,

Re: BigInt to binary

2015-04-25 Thread Ali Çehreli via Digitalmars-d-learn
On 04/25/2015 01:23 PM, Dennis Ritchie wrote: which section should apply similar requests? https://issues.dlang.org/ After clicking File and Issue: Component: Phobos Severity: Enhancement Ali

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 11:38:46 UTC, Martin Nowak wrote: On Saturday, 25 April 2015 at 05:07:04 UTC, Jens Bauer wrote: I hope to find a good way to use import for microcontroller libraries, so it'll be easy for everyone. I'm thinking about something like ... import mcu.stm32f439.all

Re: BigInt to binary

2015-04-25 Thread via Digitalmars-d-learn
On Saturday, 25 April 2015 at 13:13:10 UTC, Dennis Ritchie wrote: Hi, Is there a way to apply a function format with BigInt? - import std.stdio, std.bigint, std.string; void main() { BigInt n = -10; string s = format(%b, n); // error writeln(s); } BigInt only

Re: std.json questions

2015-04-25 Thread rcorre via Digitalmars-d-learn
On Saturday, 25 April 2015 at 09:56:25 UTC, tired_eyes wrote: A brief look at code.dlang.org gives us 7 (!) additional JSON libraries. Keeping in mind that D community isn't so huge, I think I'm not the only person struggling with std.json. Are there any plans on upgrading it? See

Re: Microcontroller startup file - supported devices wish-list

2015-04-25 Thread Rikki Cattermole via Digitalmars-d-learn
On 26/04/2015 5:53 a.m., Jens Bauer wrote: As I'm impressed with the interest in the startup-files I've made so far, I'd like to add support for more devices. In order to do so, I'd like to ask on this forum, which devices you would be interested in. Please list specific device names/numbers if

Re: Startup files for STM32F4xx

2015-04-25 Thread Timo Sintonen via Digitalmars-d-learn
On Sunday, 26 April 2015 at 00:52:56 UTC, Mike wrote: On Saturday, 25 April 2015 at 16:32:50 UTC, Timo Sintonen wrote: I think there's a few gems that can be cherry-picked out of Phobos, especially for metaprogramming: std.traits std.typecons std.typetuple There are also a couple things in

Re: Startup files for STM32F4xx

2015-04-25 Thread Brad Roberts via Digitalmars-d-learn
On 4/25/2015 10:02 PM, Timo Sintonen via Digitalmars-d-learn wrote: -Import mess. Phobos files import several other files. Some of them cannot be used. Work is going on to remove unnecessary imports and use scoped imports. It is important that imports for unittests are only in unittest blocks.

Re: How to turn an inout(Object) into a string

2015-04-25 Thread Meta via Digitalmars-d-learn
On Sunday, 26 April 2015 at 03:48:00 UTC, tcak wrote: On Sunday, 26 April 2015 at 03:09:17 UTC, Meta wrote: The following code spits out pages of error messages, and it's driving me insane. I know that Object.toString only has a mutable variant, so how am I supposed to use writeln, toString,

Re: How to turn an inout(Object) into a string

2015-04-25 Thread Meta via Digitalmars-d-learn
On Sunday, 26 April 2015 at 04:52:36 UTC, Jonathan M Davis wrote: It's only undefined if mutation is involved, though I don't know if mutation is involved in this case or not I was thinking that a class can define an arbitrary toString() that modifies it some of its member variables, which

Re: How to turn an inout(Object) into a string

2015-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 26, 2015 05:09:30 Meta via Digitalmars-d-learn wrote: On Sunday, 26 April 2015 at 04:52:36 UTC, Jonathan M Davis wrote: It's only undefined if mutation is involved, though I don't know if mutation is involved in this case or not I was thinking that a class can define an

How to turn an inout(Object) into a string

2015-04-25 Thread Meta via Digitalmars-d-learn
The following code spits out pages of error messages, and it's driving me insane. I know that Object.toString only has a mutable variant, so how am I supposed to use writeln, toString, etc. with an inout, const, or immutable object? void main(inout string[] args) { import std.stdio;

Re: How to turn an inout(Object) into a string

2015-04-25 Thread tcak via Digitalmars-d-learn
On Sunday, 26 April 2015 at 03:09:17 UTC, Meta wrote: The following code spits out pages of error messages, and it's driving me insane. I know that Object.toString only has a mutable variant, so how am I supposed to use writeln, toString, etc. with an inout, const, or immutable object? void

Re: How to turn an inout(Object) into a string

2015-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 26, 2015 03:51:25 Meta via Digitalmars-d-learn wrote: On Sunday, 26 April 2015 at 03:48:00 UTC, tcak wrote: On Sunday, 26 April 2015 at 03:09:17 UTC, Meta wrote: The following code spits out pages of error messages, and it's driving me insane. I know that Object.toString

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 06:25:08 UTC, tom wrote: On Saturday, 25 April 2015 at 04:01:47 UTC, Jens Bauer wrote: (still no automatic mirroring, though I've installed https://github.com/miracle2k/gitolite-simple-mirror) it should be fairly simple, check the logs. It's probably something

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 05:14:57 UTC, Rikki Cattermole wrote: On 25/04/2015 5:07 p.m., Jens Bauer wrote: I hope to find a good way to use import for microcontroller libraries, so it'll be easy for everyone. I'm thinking about something like ... import mcu.stm32f439.all Ugh,

Re: Startup files for STM32F4xx

2015-04-25 Thread tom via Digitalmars-d-learn
On Saturday, 25 April 2015 at 04:01:47 UTC, Jens Bauer wrote: (still no automatic mirroring, though I've installed https://github.com/miracle2k/gitolite-simple-mirror) it should be fairly simple, check the logs. most probably something failing with authentication. (btw, for those who don't know

Re: Startup files for STM32F4xx

2015-04-25 Thread Rikki Cattermole via Digitalmars-d-learn
On 25/04/2015 7:04 p.m., Jens Bauer wrote: On Saturday, 25 April 2015 at 05:14:57 UTC, Rikki Cattermole wrote: On 25/04/2015 5:07 p.m., Jens Bauer wrote: I hope to find a good way to use import for microcontroller libraries, so it'll be easy for everyone. I'm thinking about something like ...

Re: Weird OSX issue

2015-04-25 Thread Dan Olson via Digitalmars-d-learn
Jacob Carlborg d...@me.com writes: On 2015-04-24 20:37, Steven Schveighoffer wrote: So am I going crazy? Or is dmd doing things differently depending on where its environment is? Any compiler gurus out there understand why the symbol is different? I don't want to file a bug with this,

Re: Degenerate Regex Case

2015-04-25 Thread Dmitry Olshansky via Digitalmars-d-learn
On Friday, 24 April 2015 at 18:28:16 UTC, Guillaume wrote: Hello, I'm trying to make a regex comparison with D, based off of this article: https://swtch.com/~rsc/regexp/regexp1.html I've written my code like so: import std.stdio, std.regex; void main(string argv[]) { string m =

std.json questions

2015-04-25 Thread tired_eyes via Digitalmars-d-learn
Hello, D community! I'm pretty new to D and to compiled languages in general, and have primarily web background (PHP, JS), when JSON workflow is very organic. I was always sure that JSON is a simple thing, but std.json proves me wrong. So may I have a little advice from more experienced D

Delegate type deduction compile error

2015-04-25 Thread ref2401 via Digitalmars-d-learn
struct MyStruct {} void main(string[] args) { string str = blah-blah; auto d1 = (MyStruct) { writeln(delegate-str: , str); }; writeln(typeid(typeof(d1))); } dmd: 2067 os: Win8.1 build script: dmd main.d -ofconsole-app.exe -debug -unittest -wi - if delegate has no

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 07:08:26 UTC, Rikki Cattermole wrote: I was referring to package.d files. And publically importing all below modules/packages. Normally, one would want to import only the most necessary parts. Let's take an example: A microcontroller has USB, LCD controller,

Re: Startup files for STM32F4xx

2015-04-25 Thread Rikki Cattermole via Digitalmars-d-learn
On 25/04/2015 7:31 p.m., Jens Bauer wrote: On Saturday, 25 April 2015 at 07:08:26 UTC, Rikki Cattermole wrote: I was referring to package.d files. And publically importing all below modules/packages. Normally, one would want to import only the most necessary parts. Let's take an example: A

Re: Startup files for STM32F4xx

2015-04-25 Thread Jens Bauer via Digitalmars-d-learn
On Saturday, 25 April 2015 at 08:30:10 UTC, Rikki Cattermole wrote: On 25/04/2015 7:31 p.m., Jens Bauer wrote: Normally, one would want to import only the most necessary parts. Let's take an example: A microcontroller has USB, LCD controller, Ethernet, U(s)ART, SPI, CAN, I2S, I2C and also

Re: Startup files for STM32F4xx

2015-04-25 Thread Martin Nowak via Digitalmars-d-learn
On Saturday, 25 April 2015 at 07:04:58 UTC, Jens Bauer wrote: Things that can be recycled would be carefully written drivers, such as LCD drivers that uses the SPI protocol. The SPI interface itself cannot be recycled, though, as each device has different SPI hardware and different GPIO

Re: Delegate type deduction compile error

2015-04-25 Thread anonymous via Digitalmars-d-learn
On Saturday, 25 April 2015 at 10:23:25 UTC, ref2401 wrote: struct MyStruct {} void main(string[] args) { string str = blah-blah; auto d1 = (MyStruct) { writeln(delegate-str: , str); }; writeln(typeid(typeof(d1))); } dmd: 2067 os: Win8.1 build script: dmd main.d

o!(const(T)) parameter.

2015-04-25 Thread sclytrack via Digitalmars-d-learn
I want a function with parameter o!(const(Form)) to accept both o!(Form) and o!(immutable(Form)) Is there a way to do it? import std.stdio; import std.traits; class Form { int number = 10; } struct o(T) { T data; this(T data) { this.data =

Re: Startup files for STM32F4xx

2015-04-25 Thread Martin Nowak via Digitalmars-d-learn
On Saturday, 25 April 2015 at 05:07:04 UTC, Jens Bauer wrote: I hope to find a good way to use import for microcontroller libraries, so it'll be easy for everyone. I'm thinking about something like ... import mcu.stm32f439.all I think that belongs in the makefile/dub.json as

Re: Startup files for STM32F4xx

2015-04-25 Thread Martin Nowak via Digitalmars-d-learn
On Saturday, 25 April 2015 at 05:07:04 UTC, Jens Bauer wrote: While I remember it ... I had to nullify a number of imports in stdint. They simply do not belong in there. :) Eg. I do not want FILE* if I aks for stdint. But FILE* is forced upon me, because wchar_t includes it. What does a

Re: Startup files for STM32F4xx

2015-04-25 Thread Martin Nowak via Digitalmars-d-learn
On Saturday, 25 April 2015 at 07:31:45 UTC, Jens Bauer wrote: I wonder if you can get e.g. interfaces and classes working. I hope I will. ;) I think classes are really a must. The only thing that I (currently) see that could perhaps block this from working, would be missing support for

BigInt to binary

2015-04-25 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, Is there a way to apply a function format with BigInt? - import std.stdio, std.bigint, std.string; void main() { BigInt n = -10; string s = format(%b, n); // error writeln(s); }

Re: o!(const(T)) parameter.

2015-04-25 Thread anonymous via Digitalmars-d-learn
On Saturday, 25 April 2015 at 14:52:45 UTC, sclytrack wrote: I want a function with parameter o!(const(Form)) to accept both o!(Form) and o!(immutable(Form)) Is there a way to do it? import std.stdio; import std.traits; class Form { int number = 10; } struct o(T) { T

Re: o!(const(T)) parameter.

2015-04-25 Thread sclytrack via Digitalmars-d-learn
It works when you exclude the recursive alias this: static if(!is(T == const)) alias constify this; Your original program crashes the compiler, which is always a bug. I filed an issue: https://issues.dlang.org/show_bug.cgi?id=14499 Thank you, very much.

Re: Startup files for STM32F4xx

2015-04-25 Thread Timo Sintonen via Digitalmars-d-learn
Before you start to write device drivers I remind you that it is not possible to just write and read the peripheral registers via pointers. The compiler will do optimizations like omit reads and writes or reorder them. My very simple uart driver is here:

Re: std.json questions

2015-04-25 Thread Dan Olson via Digitalmars-d-learn
tired_eyes pastuho...@gmail.com writes: First issue: what is the proper (idiomatic) way to conver JSONValue to the proper types? Second: what is the proper way of handling boolean values in JSON (how to convert JSON_TYPE.TRUE and JSON_TYPE.FALSE to bool)? Righ now I'm doing is something

Re: Startup files for STM32F4xx

2015-04-25 Thread Timo Sintonen via Digitalmars-d-learn
On Saturday, 25 April 2015 at 11:56:55 UTC, Martin Nowak wrote: You better dismiss the idea of using druntime/phobos. They are not optimized for code size and contain a lot of stuff that'll never work. You can replace the core.stdc headers with bindings for nanolib, but again it's not