On Friday, July 11, 2014 04:01:24 Joel via Digitalmars-d-learn wrote:
> I've been trying to set a date for my program (a small struct):
>
> import std.datetime;
>
> auto date = cast(DateTime)Clock.currTime();
> setDate(date.day, date.month, date.year);
>
> Problem is that day & month are not intege
On Sunday, 13 July 2014 at 20:55:25 UTC, bearophile wrote:
D doesn't carry the range of mutable variables across different
expressions.
What is the reasoning behind this kind of special-casing?
Oh, thanks a lot!!
With a little change all work!
look:
struct IMAGE_DOS_HEADER {
WORD e_magic,
e_cblp,
//...
void main() {
import std.stdio;
import std.file;
import core.stdc.string;
auto dosh = cast(PIMAGE_DOS_HEADER)image.ptr;
Hi
I am trying to write some code that uses and matches to regular
expressions at compile time, but the compiler won't let me
because matchFirst and matchAll make use of malloc().
Is there an alternative that I can use that can be run at compile
time?
Thanks in advance.
Jason
Alexandre:
When the PE file is generate in EXE have just the "M" of "MZ"...
Let's try again, is this better?
import std.c.windows.windows: WORD, LONG;
struct IMAGE_DOS_HEADER {
WORD e_magic = ('M' << 8) + 'Z',
e_cblp,
e_cp,
e_crlc,
e_cparhdr,
On 07/13/2014 05:21 PM, Alexandre wrote:
Ok, thanks thanks!!!
Have a lot of thinks I need to learn
When I generate the exe file, something is wrong with this:
dosh.e_magic = cast(WORD)*"MZ".ptr;
When the PE file is generate in EXE have just the "M" of "MZ"...
You put the * outside the cas
Ok, thanks thanks!!!
Have a lot of thinks I need to learn
When I generate the exe file, something is wrong with this:
dosh.e_magic = cast(WORD)*"MZ".ptr;
When the PE file is generate in EXE have just the "M" of "MZ"...
On Friday, 11 July 2014 at 17:43:53 UTC, Ali Çehreli wrote:
Ali
Thx
Meta:
It seems that not even that is the case.
void main()
{
uint n = 0;
//Error
bool b = n;
}
D doesn't carry the range of mutable variables across different
expressions.
So write (with the 2.066beta3):
void main() {
const uint x1 = 0;
const uint x2 = 1;
Marc Schütz:
Better use `ubyte[0x800] image` here. `char[]` is only for
UTF-8 strings.
Right, sorry.
Bye,
bearophile
On Sunday, 13 July 2014 at 18:48:01 UTC, Alexandre wrote:
char image[0x800];
Better use `ubyte[0x800] image` here. `char[]` is only for UTF-8
strings.
Alexandre:
WORD e_res[4];
In D it's better to write:
WORD[4] e_res;
char image[0x800];
Note this is a thread-local variable. If you need a module-local
variable you have to write:
__gshared char[0x800] image;
void main(string[] args)
If you don't need the args, then w
On Sunday, 13 July 2014 at 18:48:01 UTC, Alexandre wrote:
dosh.e_magic = cast(WORD*)("MZ");
should be:
dosh.e_magic = cast(WORD*)("MZ".ptr);
On Sunday, 13 July 2014 at 19:06:29 UTC, Timon Gehr wrote:
On 07/13/2014 08:51 PM, Meta wrote:
That's weird, I always assumed this worked. Was it always the
case that
numeric types can't be implicitly casted to bool?
Yes, unless their range fits into [0,2).
It seems that not even that is
On 07/13/2014 08:51 PM, Meta wrote:
That's weird, I always assumed this worked. Was it always the case that
numeric types can't be implicitly casted to bool?
Yes, unless their range fits into [0,2).
On Sunday, 13 July 2014 at 11:18:05 UTC, bearophile wrote:
The idea of not making std.algorithm.among!() a predicate was
not so good:
void main() {
import std.stdio, std.algorithm;
auto s = "hello how\nare you";
s.until!(c => c.among!('\n', '\r')).writeln;
}
(A normal workaround
I have this code in C++
//...
char image[0x800];
//...
auto dosh = reinterpret_cast(&image[0]);
dosh->e_magic = *(WORD*)"MZ";
dosh->e_cblp = 0x90;
dosh->e_cp = 3;
dosh->e_cparhdr = 4;
dosh->e_maxalloc = 0x;
dosh->e_sp = 0xb8;
dosh->e_lfarlc = 0x40;
dosh
On 13/07/14 19:51, Brian Rogoff via Digitalmars-d-learn wrote:
Yes, the same argument for books and slides is also applicable to all other
media.
Not really. In a book or a slide you have an unavoidable constraint on how much
vertical space you can take up. On a screen, you are unavoidably g
On 07/13/2014 07:51 PM, Brian Rogoff wrote:
On Sunday, 13 July 2014 at 17:24:40 UTC, Timon Gehr wrote:
On 07/13/2014 06:45 PM, Joseph Rushton Wakeling via
Digitalmars-d-learn wrote:
Wrong. There are things which are simply bad ideas.
E.g. in this case, "Egyptian"-style braces definitely make y
Timon Gehr:
I am saying the following code implementing 'until' in
std.algorithm is at fault:
private bool predSatisfied() // <-- don't say bool here
{
static if (is(Sentinel == void))
return unaryFun!pred(_input.front); // or cast here
else
retu
On 13/07/14 19:24, Timon Gehr via Digitalmars-d-learn wrote:
Wrong. There are things which are simply bad ideas.
I think that we can take it as read that I meant, "Any reasonable stylistic
choice." Of course, YMMV about what counts as "reasonable", but most of the
things that people fuss ove
On Sunday, 13 July 2014 at 17:24:40 UTC, Timon Gehr wrote:
On 07/13/2014 06:45 PM, Joseph Rushton Wakeling via
Digitalmars-d-learn wrote:
Wrong. There are things which are simply bad ideas.
E.g. in this case, "Egyptian"-style braces definitely make
your code
more compact,
I.e. you see where
On 07/13/2014 06:45 PM, Joseph Rushton Wakeling via Digitalmars-d-learn
wrote:
Two consequences of adapting myself to Phobos style were that I realized
(i)how little most of these things really matter, and (ii) pretty much
any stylistic choice carries both benefits and drawbacks.
...
Wrong. T
Danyal Zia:
I noticed that in Andrei's talks and his book, he used braces
on the same line of delcaration, however Phobos and other D
libraries I know use braces on their own line.
Rosettacode D examples always use the Egyptian style. For my code
I use the same style, but Phobos contribution
On Sunday, 13 July 2014 at 16:47:00 UTC, Joseph Rushton Wakeling
via Digitalmars-d-learn wrote:
On 13/07/14 14:23, Danyal Zia via Digitalmars-d-learn wrote:
I'm going with Andrei's style of preference on his talks ;)
Andrei can no doubt speak for himself about his preferences,
but I'd be wary
On 13/07/14 14:23, Danyal Zia via Digitalmars-d-learn wrote:
I'm going with Andrei's style of preference on his talks ;)
Andrei can no doubt speak for himself about his preferences, but I'd be wary of
assuming that the style he uses in his talks necessarily reflects his actual
stylistic prefe
On 13/07/14 16:52, H. S. Teoh via Digitalmars-d-learn wrote:
I had my own style before, but after I started contributing to Phobos, I
found it a pain to keep switching back and forth between styles (and to
convert styles before submitting PR's), so eventually I decided to just
adopt Phobos style
On Saturday, 12 July 2014 at 19:01:56 UTC, Danyal Zia wrote:
Hi,
I noticed that in Andrei's talks and his book, he used braces
on the same line of delcaration, however Phobos and other D
libraries I know use braces on their own line. Now I'm in a
position where I need to take decision on codi
On Saturday, 12 July 2014 at 17:11:00 UTC, Rainer Schuetze wrote:
On 12.07.2014 19:05, Rainer Schuetze wrote:
Thanks for the reduction. GC.realloc seems broken for
reallocations to
sizes larger than the current GC pool.
Please file a bug report.
Actually done that myself:
https://issues
On Sun, Jul 13, 2014 at 11:32:23AM +0200, Joseph Rushton Wakeling via
Digitalmars-d-learn wrote:
> On 12/07/14 21:01, Danyal Zia via Digitalmars-d-learn wrote:
> >I noticed that in Andrei's talks and his book, he used braces on the
> >same line of delcaration, however Phobos and other D libraries
On Sunday, 13 July 2014 at 13:38:34 UTC, Xiaoxi wrote:
If I want to build a d program which works on all dists, can i
build that from any linux machine since dmd links statically by
default or should I chose the oldest, i.e rhel5 to build on?
because of possible glibc issues?
Using machine w
Hi,
at home I run, osx, windows and freebsd, all work fine with D.
However our servers at work run linux RHEL5, RHEL6.4 and our
workstations run Ubuntu... can i use feodora rpm for rhel?
If I want to build a d program which works on all dists, can i
build that from any linux machine since d
On 07/13/2014 03:09 PM, bearophile wrote:
Timon Gehr:
It works with filter, so I think it should just work with until as well.
So do you suggest me to open a bug report where I ask "among" to return
a bool, or do you suggest to ask for an enhancement of "until", or what?
Bye,
bearophile
I
Timon Gehr:
It works with filter, so I think it should just work with until
as well.
So do you suggest me to open a bug report where I ask "among" to
return a bool, or do you suggest to ask for an enhancement of
"until", or what?
Bye,
bearophile
On 07/13/2014 01:18 PM, bearophile wrote:
The idea of not making std.algorithm.among!() a predicate was not so good:
...
Agreed.
void main() {
import std.stdio, std.algorithm;
auto s = "hello how\nare you";
s.until!(c => c.among!('\n', '\r')).writeln;
}
(A normal workaround
On Sunday, 13 July 2014 at 10:18:23 UTC, Joseph Rushton Wakeling
via Digitalmars-d-learn wrote:
However, I do think there's value in deliberately matching the
code style of the standard library, as it extends the volume of
public D code with a common style.
So unless you have a strong personal
On Sunday, 13 July 2014 at 11:18:05 UTC, bearophile wrote:
The idea of not making std.algorithm.among!() a predicate was
not so good:
void main() {
import std.stdio, std.algorithm;
auto s = "hello how\nare you";
s.until!(c => c.among!('\n', '\r')).writeln;
}
(A normal workaround
The idea of not making std.algorithm.among!() a predicate was not
so good:
void main() {
import std.stdio, std.algorithm;
auto s = "hello how\nare you";
s.until!(c => c.among!('\n', '\r')).writeln;
}
(A normal workaround is to use !!c.among!).
Bye,
bearophile
On 12/07/14 21:01, Danyal Zia via Digitalmars-d-learn wrote:
I noticed that in Andrei's talks and his book, he used braces on the same line
of delcaration, however Phobos and other D libraries I know use braces on their
own line. Now I'm in a position where I need to take decision on coding style
On Sunday, 13 July 2014 at 01:01:16 UTC, Ellery Newcomer wrote:
would psutils itself be acceptable?
https://bitbucket.org/ariovistus/pyd
I haven't thought about this possibility, thanks.
On 7/13/2014 2:28 PM, Israel Rodriguez wrote:
What about the dub libraries, what kind of errors do you get if you try
to use a library not compatible for your system, say OSX or Linux? Im
assuming the same linking errors but im not sure.
dub doesn't download library binaries, but the source. I
On Friday, 11 July 2014 at 15:45:42 UTC, Chris wrote:
Tried to compile on linux, got this error message (I guess I
can fix it):
dmd -c textgen.d
textgen.d(36): Error: cannot implicitly convert expression
("DMDScript fatal runtime error: ") of type string to char[]
.. bunch more errors.
You m
42 matches
Mail list logo