Please let me know how you did it, because I know it's possible
with the DIY-cartridge they provide you(atleast it should be).
I tried it some time ago. It is possible but:
- vibe.d requires a lot of memory for project compilation
- it is hard to install additional libraries (it is not
So, I have this code (also on http://dpaste.dzfl.pl/3f767b17e83c)
This Vector(T) struct is taken from gfm.math.vector.
struct Vector(T) {
T x, y, z;
this(X : T, Y : T, Z : T)(X x_, Y y_, Z z_)
{
x = x_; y = y_; z = z_;
}
}
void main()
{
francesco cattoglio:
should this code compile? I understand that the literal 1 is
int therefore it can screw type deduction, but I wonder if
the compiler should be smart enough to deduce it correctly.
To keep both the compiler and programmers sane, D templates don't
perform implicit type
On Thursday, 24 July 2014 at 09:38:14 UTC, bearophile wrote:
francesco cattoglio:
should this code compile? I understand that the literal 1 is
int therefore it can screw type deduction, but I wonder if
the compiler should be smart enough to deduce it correctly.
To keep both the compiler and
I first try to load the file as utf8 (or some 8kb at the start of
it) with encoding exceptions turned on, if I catch an exception,
I reload it as ansi, otherwise I assume it's valid utf8.
On 2014-07-24 3:45 AM, Nikolay wrote:
Please let me know how you did it, because I know it's possible
with the DIY-cartridge they provide you(atleast it should be).
I tried it some time ago. It is possible but:
- vibe.d requires a lot of memory for project compilation
- it is hard to
On Thursday, 24 July 2014 at 02:48:45 UTC, Rutger wrote:
On Thursday, 24 July 2014 at 01:47:43 UTC, Rikki Cattermole
wrote:
On 24/07/2014 1:28 p.m., Rutger wrote:
Hello! Really enjoying D so far and have started to toy around
with Vibe.d.
I was just wondering if someone here has had any
I'm trying to add gzip compression to a HTTP server i wrote in D.
here is the code that dose the gzip encoding.
if ((Info.modGzip)
(indexOf(client.getRequestHeaderFieldValue(Accept-Encoding),gzip)
!= -1)){
writeln(gzip);
auto gzip = new Compress(HeaderFormat.gzip);
I have the following code in fac.d (modified from the factorial
examples on RosettaCode):
#!/usr/bin/rdmd
import std.bigint;
pure BigInt factorial(BigInt n) {
static pure BigInt inner(BigInt n, BigInt acc) {
return n == 0 ? acc : inner(n - 1, acc * n);
}
return inner(n,
On Thursday, 24 July 2014 at 13:09:53 UTC, Sean Campbell wrote:
I'm trying to add gzip compression to a HTTP server i wrote in
D. here is the code that dose the gzip encoding.
I know zlib gzip works for http, I used it in my cgi.d
if(gzipResponse acceptsGzip isAll) {
On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote:
I have the following code in fac.d (modified from the factorial
examples on RosettaCode):
#!/usr/bin/rdmd
import std.bigint;
pure BigInt factorial(BigInt n) {
static pure BigInt inner(BigInt n, BigInt
On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via
Digitalmars-d-learn wrote:
I have the following code in fac.d (modified from the factorial
examples on RosettaCode):
#!/usr/bin/rdmd
import std.bigint;
On Thursday, 24 July 2014 at 14:59:16 UTC, Darren wrote:
On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via
Digitalmars-d-learn wrote:
I have the following code in fac.d (modified from the
factorial
On Thu, 24 Jul 2014 15:15:36 +, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto parsed = parseJSON(jsonStr);
string s =
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
string s = parsed[fail].str;
Since there is no entry fail in the object, it returns a null
JSON_VALUE pointer. Trying to get the string out of it is then
seen as a null pointer access and kills the program.
Check for null on a key
Ok, let me start with the sample code:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto parsed = parseJSON(jsonStr);
string s = parsed[fail].str;
writeln(s == );
writeln(s is null);
writeln(s);
}
Adam D. Ruppe:
Check for null on a key before trying to get a value out.
Is something like the get() function usable here?
Bye,
bearophile
On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
string s = parsed[fail].str;
Since there is no entry fail in the object, it returns a null
JSON_VALUE pointer. Trying to get the string out of it is then
seen as a null
Am 24.07.2014 17:29, schrieb Pavel:
On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
string s = parsed[fail].str;
Since there is no entry fail in the object, it returns a null
JSON_VALUE pointer. Trying to get the string
On 07/24/2014 08:29 AM, Pavel wrote:
writeln(parsed[fail] == null);
Now compiler complains:
Error: incompatible types for ((parsed.opIndex(fail)) == (null)):
'JSONValue' and 'typeof(null)'
WAT?!
Comparing against null should be done with the 'is' operator, not the ==
operator:
if
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto parsed = parseJSON(jsonStr);
string s = parsed[fail].str;
On Thursday, 24 July 2014 at 15:31:30 UTC, Daniel Gibson wrote:
Am 24.07.2014 17:29, schrieb Pavel:
On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
string s = parsed[fail].str;
Since there is no entry fail in the
On Thursday, 24 July 2014 at 15:20:58 UTC, Justin Whear wrote:
On Thu, 24 Jul 2014 15:15:36 +, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto
On Thursday, 24 July 2014 at 14:59:16 UTC, Darren wrote:
It does seem that's the case. Which is odd, as I thought that
DMD and LDC did TCO. Not in this case obviously.
DMD doesn't do it with the :? operator:
https://issues.dlang.org/show_bug.cgi?id=3713
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto
On Thursday, 24 July 2014 at 15:34:22 UTC, Ali Çehreli wrote:
On 07/24/2014 08:29 AM, Pavel wrote:
writeln(parsed[fail] == null);
Now compiler complains:
Error: incompatible types for ((parsed.opIndex(fail)) ==
(null)):
'JSONValue' and 'typeof(null)'
WAT?!
Comparing against null should
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote:
On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
import std.json;
void main() {
scope(failure)
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote:
On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
Ok, let me start with the sample code:
import std.stdio;
On Thursday, 24 July 2014 at 15:48:32 UTC, Edwin van Leeuwen
wrote:
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote:
On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:15:37 UTC,
Am 24.07.2014 17:54, schrieb Pavel:
Guess what, here's a new snippet:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto parsed = parseJSON(jsonStr).object;
writeln(fail in parsed);
}
Output is:
null
Pavel:
writeln(cast(bool)(fail in parsed));
Produces false... but why on earth boolean expression would
output null?
In D if you perform an associative array in, the return isn't a
boolean but a pointer. It's zero if the item is not present. And
it's a valid pointer to the value if the
On Thu, Jul 24, 2014 at 03:54:20PM +, Pavel via Digitalmars-d-learn wrote:
[...]
Guess what, here's a new snippet:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto parsed =
On Thursday, 24 July 2014 at 15:59:52 UTC, Daniel Gibson wrote:
Am 24.07.2014 17:54, schrieb Pavel:
Guess what, here's a new snippet:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
string jsonStr = `{ name: 1, type: r }`;
auto parsed =
On Thu, 24 Jul 2014 15:54:20 +, Pavel wrote:
On Thursday, 24 July 2014 at 15:48:32 UTC, Edwin van Leeuwen wrote:
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote:
On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin
On Thursday, 24 July 2014 at 15:54:21 UTC, Pavel wrote:
On Thursday, 24 July 2014 at 15:48:32 UTC, Edwin van Leeuwen
wrote:
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote:
On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote:
On Thursday, 24 July 2014 at 15:32:29 UTC, John
On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote:
Thanks to all you folks who explained in operator for me. My bad.
Let's focus on the real problem, which is JSON wrapper class. Is it
needed? Wouldn't it be better to get AA from parseJSON?
The following are valid JSON:
auto json1 =
1 class Test
2 {
3 int[][] array;
4 this(ref int[][] d)
5 {
6 array = d;
7 }
8
9 }
10
11 void main()
12 {
13 Test t = new Test([[1,1],[1,1]]); //does not compile
14 }
15
what is the best way to pass a literal ([[1,2],[3,4]]) by
reference?
On Thursday, 24 July 2014 at 16:02:12 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Thu, Jul 24, 2014 at 03:54:20PM +, Pavel via
Digitalmars-d-learn wrote:
[...]
Guess what, here's a new snippet:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln(FaILED!!);
On Thursday, 24 July 2014 at 16:09:25 UTC, Justin Whear wrote:
On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote:
Thanks to all you folks who explained in operator for me. My
bad.
Let's focus on the real problem, which is JSON wrapper class.
Is it
needed? Wouldn't it be better to get AA from
On Thursday, 24 July 2014 at 16:06:00 UTC, Rishub Nagpal wrote:
1 class Test
2 {
3 int[][] array;
4 this(ref int[][] d)
5 {
6 array = d;
7 }
8
9 }
10
11 void main()
12 {
13 Test t = new Test([[1,1],[1,1]]); //does not compile
14 }
15
what
On 7/24/14, 1:09 PM, Justin Whear wrote:
On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote:
Thanks to all you folks who explained in operator for me. My bad.
Let's focus on the real problem, which is JSON wrapper class. Is it
needed? Wouldn't it be better to get AA from parseJSON?
The
On Thu, 24 Jul 2014 13:49:27 -0300, Ary Borenszweig wrote:
Nope, a JSON can only be an array or an object (hash).
Ary, can you point out the place in the spec where this is specified?
Not to be pedantic, but the spec only seems to define a JSON value, not
a JSON document.
On Thu, 24 Jul 2014 16:14:15 +, Pavel wrote:
On Thursday, 24 July 2014 at 16:09:25 UTC, Justin Whear wrote:
On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote:
Thanks to all you folks who explained in operator for me. My bad.
Let's focus on the real problem, which is JSON wrapper class. Is
On Thu, 24 Jul 2014 17:05:17 +, Gary Willoughby wrote:
I was reading Ali's book (http://ddili.org/ders/d.en/index.html)
and saw this piece of code on how to get the true size of an object:
MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize,
MyClass) * 10);
That got
I was reading Ali's book (http://ddili.org/ders/d.en/index.html)
and saw this piece of code on how to get the true size of an
object:
MyClass* buffer =
cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) *
10);
That got me thinking, how would i actually 'fill' this memory
with
Am 24.07.2014 19:05, schrieb Gary Willoughby:
I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw
this piece of code on how to get the true size of an object:
MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize,
MyClass) * 10);
That got me thinking, how
On Thursday, 24 July 2014 at 17:05:18 UTC, Gary Willoughby wrote:
I was reading Ali's book
(http://ddili.org/ders/d.en/index.html) and saw this piece of
code on how to get the true size of an object:
MyClass* buffer =
cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) *
10);
On Thu, 24 Jul 2014 17:07:29 +, Justin Whear wrote:
On Thu, 24 Jul 2014 17:05:17 +, Gary Willoughby wrote:
I was reading Ali's book (http://ddili.org/ders/d.en/index.html)
and saw this piece of code on how to get the true size of an object:
MyClass* buffer =
Hello,
I am writing an application that connects to a serial device in
/dev/ttyUSB0 and trows some binary data back and forth.
How can i mock and run some unit testing without having to
connect to the device every time?
--
Regards,
Alfredo Palhares
I was playing around with use of the dual WITH statement. I
like the idea, since it makes the code within the with cleaner.
Also, I got the impression from one of the conference
presentations ... maybe the one on the ARM debug ... that there
are some additional optimizations available that
On Thu, 24 Jul 2014 17:15:02 +, Alfredo Palhares wrote:
Hello,
I am writing an application that connects to a serial device in
/dev/ttyUSB0 and trows some binary data back and forth.
How can i mock and run some unit testing without having to connect to
the device every time?
How
Hello,
How about capturing some data from the device and writing it to
a file?
When you want to test, open the test data file instead of the
device file.
That would not work since the data is two way, for the device to
even trow data at me I need to send some values to it.
--
Regards,
Is there a big reason why Appender.put doesn't return this?
http://dpaste.dzfl.pl/bb840e3e349e
It would allow for convenient chaining. :
Offtop
It's better to return this and have return type ref auto i
think.
On 7/24/14, 1:58 PM, Justin Whear wrote:
On Thu, 24 Jul 2014 13:49:27 -0300, Ary Borenszweig wrote:
Nope, a JSON can only be an array or an object (hash).
Ary, can you point out the place in the spec where this is specified?
Not to be pedantic, but the spec only seems to define a JSON value,
Hi!
Can I somehow make a general array where I can store everykind of
object? doubles, ints, float, class objects? Or is there any
method for it?
58 matches
Mail list logo