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 usual
On Wednesday, 23 July 2014 at 16:46:04 UTC, FreeSlave wrote:
On Wednesday, 23 July 2014 at 15:35:59 UTC, Chris wrote:
The C++ code does this:
size_t fwrite ( const void * ptr, size_t size, size_t count,
FILE * stream );
// stream is stdout
and text appears in the console (a string).
I don't
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()
{
Ve
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
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 inst
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 experie
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, BigI
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, Big
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;
pure
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
examples
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 ke
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);
writel
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 nul
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 str
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:
i
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"
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 obj
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" }`;
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" }`;
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 sho
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" }`;
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) writeln("F
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, Pav
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
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 t
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 = parseJ
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 = parse
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 C
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 Colv
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 = pars
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? Is
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 is
On Thursday, 24 July 2014 at 16:15:44 UTC, John Colvin wrote:
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]
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 followi
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 wrap
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);
>
> Tha
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 ins
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 wou
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);
That
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 = cast(MyClass*
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?
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,
Alf
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?
On Thursday, 24 July 2014 at 19:43:23 UTC, Robert Rimoczi wrote:
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?
void main()
{
import std.variant, std.stdio;
class Four { overrid
On Thursday, 24 July 2014 at 17:07:47 UTC, Justin Whear wrote:
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
On Thursday, 24 July 2014 at 17:19:36 UTC, Jay Norwood wrote:
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 ...
On Thursday, 24 July 2014 at 17:19:36 UTC, Jay Norwood wrote:
Anyway, a problem I ran into was if two structures had the same
member names, for example struct ar.r and ar.psm in this case
below. In this case, there was no way for the compiler to
determine from which structure to get the membe
monarch_dodra:
From what I can observe, the compiler resolves the ambiguity by
chosing the first match in terms of scope. Eg, there's
shadowing. From my previous code:
with (t)
{
writeln(k); //prints t.k
with(s)
{
writeln(k); //prints s.k: it is now shadowing t.k
A re
On Thursday, 24 July 2014 at 18:49:27 UTC, Ary Borenszweig wrote:
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?
On Thursday, 24 July 2014 at 17:43:36 UTC, JR wrote:
Is there a big reason why Appender.put doesn't return &this?
http://dpaste.dzfl.pl/bb840e3e349e
It would allow for convenient chaining. :<
AFAIK, no reason no. That said, it wouldn't be useable in generic
code.
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 20:16:53 UTC, monarch_dodra wrote:
Or did I miss something?
Yes, sorry, I should have pasted a full example previously. The
code at the end is with the Raw_met members renamed (they were
originally a and b but clashed).
So, if Raw_met members were still a and b
You should compile and test on a CentOS 6.3 machine first and
then write the cartridge using the wget command to move the
same libevent package and the compiled vibe.d binary. You won't
be able to compile on a cartridge.
Yes but what if I use some additional libriaries? Every new
librar
70 matches
Mail list logo