On Friday, 11 July 2014 at 14:48:26 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Fri, Jul 11, 2014 at 10:23:58AM -0300, Ary Borenszweig via
Digitalmars-d-learn wrote:
On 7/11/14, 4:46 AM, bearophile wrote:
>pgtkda:
>
>>How can i get the number of items which are currently hold
>>in a
>>DL
> Hmm.
> So how do I use stuff like this:
>
> template defaultInit(T)
> {
> static if (!is(typeof({ T v = void; })))// inout(U)
> @property T defaultInit(T v = T.init);
> else
> @property T defaultInit();
> }
>
> (this is from std.traits - ok,
On Mon, Jul 14, 2014 at 3:19 PM, Artur Skawina via Digitalmars-d-learn
wrote:
> On 07/14/14 13:42, Philippe Sigaud via Digitalmars-d-learn wrote:
>> asserts get an entire copy of the parse tree. It's a bit wasteful, but
>> using 'immutable' directly does not work here, but this is OK:
>>
>> en
On Tue, Jul 15, 2014 at 02:49:55AM +, WhatMeWorry via Digitalmars-d-learn
wrote:
> Sorry if this is an incredibly naive question.
>
> I prefer to pragmatically pause my programs periodically so that I can
> peruse output statements. Ideally, I'd like to continue by just hitting any
> old key.
Sorry if this is an incredibly naive question.
I prefer to pragmatically pause my programs periodically so that
I can peruse output statements. Ideally, I'd like to continue by
just hitting any old key. My feeble attempt below requires I
enter at least one character and then the enter key.
c
On Tuesday, 15 July 2014 at 00:19:15 UTC, Ali Çehreli wrote:
On 07/14/2014 05:10 PM, Ali Çehreli wrote:
> On 07/14/2014 04:04 PM, H. S. Teoh via Digitalmars-d-learn
wrote:
>
> > On Mon, Jul 14, 2014 at 09:12:30PM +, Klb via
Digitalmars-d-learn
> wrote:
> >> hello what is the right syntax f
On 07/14/2014 05:10 PM, Ali Çehreli wrote:
> On 07/14/2014 04:04 PM, H. S. Teoh via Digitalmars-d-learn wrote:
>
> > On Mon, Jul 14, 2014 at 09:12:30PM +, Klb via Digitalmars-d-learn
> wrote:
> >> hello what is the right syntax for this:
> >>
> >> -
On 07/14/2014 04:04 PM, H. S. Teoh via Digitalmars-d-learn wrote:
> On Mon, Jul 14, 2014 at 09:12:30PM +, Klb via Digitalmars-d-learn
wrote:
>> hello what is the right syntax for this:
>>
>>
>> import std.stdio, std.conv;
>>
>> void main(
Nordlöw:
https://github.com/nordlow/justd/blob/master/random_ex.d#L53
Isn't @trusted mostly for small parts of Phobos code? I suggest
to avoid using @trusted in most cases.
Bye,
bearophile
On Monday, 14 July 2014 at 22:45:29 UTC, Nordlöw wrote:
So I guess we need something more than just isValidCodePoint
right?
Here's a first try:
https://github.com/nordlow/justd/blob/master/random_ex.d#L53
On Monday, 14 July 2014 at 22:32:25 UTC, bearophile wrote:
Brad Anderson:
Alternative:
randomSample(lowercase, 10, lowercase.length).writeln;
From randomSample docs:
Selects a random subsample out of r, containing exactly n
elements. The order of elements is the same as in the original
ra
On Mon, Jul 14, 2014 at 09:12:30PM +, Klb via Digitalmars-d-learn wrote:
> hello what is the right syntax for this:
>
>
> import std.stdio, std.conv;
>
> void main(string args[])
> {
> ubyte[3] src = [0, 1, 2];
> string trg = "";
>
On Monday, 14 July 2014 at 22:39:15 UTC, bearophile wrote:
Several combinations of unicode chars are not meaningful/valid
(like pairs of ligatures). Any thing that has to work correctly
with Unicode is complex.
So I guess we need something more than just isValidCodePoint
right?
On Monday, 14 July 2014 at 22:39:08 UTC, Nordlöw wrote:
might be were to start.
Is it really this simple?
bool isValidCodePoint(dchar c)
{
return c < 0xD800 || (c >= 0xE000 && c < 0x11);
}
Nordlöw:
I believe defining a complete random sampling of all code units
in dchar is a good start right? This can then be reused to
lazily convert while filling in a string and wstring.
Several combinations of unicode chars are not meaningful/valid
(like pairs of ligatures). Any thing that h
Nordlöw:
I was specifically interested in something that exercises
(random samples) potentially _all_ code points for string,
wstring and dstring (all code units that is).
That's harder. Generating all uints and then testing if it's a
Unicode dchar seems possible.
Bye,
bearophile
On Monday, 14 July 2014 at 22:35:59 UTC, Nordlöw wrote:
On Monday, 14 July 2014 at 22:32:51 UTC, Nordlöw wrote:
I believe defining a complete random sampling of all code units
in dchar is a good start right? This can then be reused to
lazily convert while filling in a string and wstring.
isV
On Monday, 14 July 2014 at 22:32:51 UTC, Nordlöw wrote:
I believe defining a complete random sampling of all code units
in dchar is a good start right? This can then be reused to lazily
convert while filling in a string and wstring.
On Monday, 14 July 2014 at 22:21:36 UTC, bearophile wrote:
Nordlöw:
Is there a natural way of generating/filling a
string/wstring/dstring of a specific length with random
contents?
Do you mean something like this?
import std.stdio, std.random, std.ascii, std.range, std.conv;
string genRan
Brad Anderson:
Alternative:
randomSample(lowercase, 10, lowercase.length).writeln;
From randomSample docs:
Selects a random subsample out of r, containing exactly n
elements. The order of elements is the same as in the original
range.<
Bye,
bearophile
On Monday, 14 July 2014 at 22:27:48 UTC, Nordlöw wrote:
and then it hangs with same behaviour.
It finally got through...hmm maybe I'm on a slow 3g-network
currently...
On Monday, 14 July 2014 at 22:10:01 UTC, Nordlöw wrote:
On Monday, 14 July 2014 at 22:08:58 UTC, Nordlöw wrote:
dub upgrade also hangs.
also at 12 percent cpu usage.
After removal of ~/.dub I did
du[per:/home/per/justd] master(+13/-4,1) ± dub
Fetching logger 0.1.0 (getting selected version)
On Monday, 14 July 2014 at 22:27:57 UTC, Brad Anderson wrote:
Alternative:
randomSample(lowercase, 10, lowercase.length).writeln;
std.ascii should really be using std.encoding.AsciiString. Then
that length wouldn't be necessary.
On Monday, 14 July 2014 at 22:21:36 UTC, bearophile wrote:
Nordlöw:
Is there a natural way of generating/filling a
string/wstring/dstring of a specific length with random
contents?
Do you mean something like this?
import std.stdio, std.random, std.ascii, std.range, std.conv;
string genRan
Nordlöw:
Is there a natural way of generating/filling a
string/wstring/dstring of a specific length with random
contents?
Do you mean something like this?
import std.stdio, std.random, std.ascii, std.range, std.conv;
string genRandomString(in size_t len) {
return len
.iota
Is there a natural way of generating/filling a
string/wstring/dstring of a specific length with random contents?
On Monday, 14 July 2014 at 22:08:58 UTC, Nordlöw wrote:
dub upgrade also hangs.
also at 12 percent cpu usage.
On Monday, 14 July 2014 at 21:50:51 UTC, Nordlöw wrote:
My dub built from git master has suddenly started to hang on
dub upgrade also hangs.
On 07/14/2014 02:34 PM, ponce wrote:
> On Monday, 14 July 2014 at 18:43:36 UTC, Ali Çehreli wrote:
>> On 07/14/2014 10:35 AM, ponce wrote:
>>
>> > Ok, solved it, I just use pointer casts and it seems to work
>> when the
>> > struct is sliced.
>>
>> I think there is a terminology issue here. Slici
On Monday, 14 July 2014 at 21:47:20 UTC, Nordlöw wrote:
My dub built from git master has suddenly started to hang on
During hang:
- dub CPU system usage is about 12 percent
- No dmd process currently activate
- End of output from strace dub:
lstat("source/app.d", {st_mode=S_IFREG|0664, st_siz
My dub built from git master has suddenly started to hang on most
commands in my project.
What to do?
Is there some cleanup I can try?
/Per
On Monday, 14 July 2014 at 18:43:36 UTC, Ali Çehreli wrote:
It is guaranteed by the language spec that yes, myFunction()
takes an A by reference. However, you can't know where that A
is coming from; so, the safety of that cast is up to you.
Consider:
void foo(A a) // <-- Already slice
On Monday, 14 July 2014 at 18:43:36 UTC, Ali Çehreli wrote:
On 07/14/2014 10:35 AM, ponce wrote:
> Ok, solved it, I just use pointer casts and it seems to work
when the
> struct is sliced.
I think there is a terminology issue here. Slicing cannot be
undone; once the object is sliced, the non-A
My idea is to use (at least test) DMDScript for server side JS.
I don't mean to sound like a D-hater here, but V8 has had about 2
years more work on it than DMDScript. At one time they were.
IIRC, quite close performance-wise but lots of work and support
by Google have probably levered past
hello what is the right syntax for this:
import std.stdio, std.conv;
void main(string args[])
{
ubyte[3] src = [0, 1, 2];
string trg = "";
@property ubyte[3] srcAsProp(){return src;}
// Error: template std.conv.to cannot dedu
I'm just guessing, but it looks to me that the delegate's pointer
might be on the stack there and isn't overwritten when the one
function returns, so the gc still thinks there might be an active
pointer to it.
On 07/14/2014 10:35 AM, ponce wrote:
> Ok, solved it, I just use pointer casts and it seems to work when the
> struct is sliced.
I think there is a terminology issue here. Slicing cannot be undone;
once the object is sliced, the non-A parts are gone.
> On Monday, 14 July 2014 at 13:23:57 UTC,
Hello everybody. I am new to D, and I am trying to familiarize
with all the new (to me) features.
I have a question about a strange behavior I cannot understand.
(In case it matters, I am using gdc 2.065 for Windows, but the
same happens with dmd).
Example code :
class A {
void de
http://dlang.org/phobos/std_typecons.html#.BlackHole
http://dlang.org/phobos/std_typecons.html#.WhiteHole
http://dlang.org/phobos/std_typecons.html#.AutoImplement
?
There's some handy refection stuff in there too:
https://github.com/nomad-software/dunit/blob/master/source/dunit/reflection.d
On Monday, 14 July 2014 at 14:45:01 UTC, Frustrated wrote:
Is there a way to take an interface and implement it
generically? e.g., All functions are implemented either as
throw and/or return defaults and properties are implemented as
getter/setters.
This is for mocking up so I a simple way to
Ok, solved it, I just use pointer casts and it seems to work when
the struct is sliced.
On Monday, 14 July 2014 at 13:23:57 UTC, ponce wrote:
Hi,
I am porting C++ code that undo "Object Slicing" by casting
const-references:
http://en.wikipedia.org/wiki/Object_slicing
My translation in D C
Alexandre:
void InjectData(T)(ref T BaseSrc, string data)
{
memcpy(&BaseSrc, data.ptr, data.length);
}
It's possible to improve this function ?
You can add some modifiers (like @nogc for dmd 2.066), and the
name of D functions starts with a lower case.
Bye,
bearophile
void InjectData(T)(ref T BaseSrc, string data)
{
memcpy(&BaseSrc, data.ptr, data.length);
}
It's possible to improve this function ?
On Monday, 14 July 2014 at 15:45:19 UTC, bearophile wrote:
Alexandre:
Look the complete code:
https://gist.github.com/bencz/3576dfc8a217a34c05a9
I kno
Alexandre:
Look the complete code:
https://gist.github.com/bencz/3576dfc8a217a34c05a9
I know, has several things that can be improved
memcpy(&dosh.e_magic, "MZ".ptr, 2);
memcpy(&peh.Signature, "PE\0\0".ptr, 4);
memcpy(scth[1].Name.ptr, ".idata".ptr, 6);
memcpy(scth[2].Name.ptr, ".data".ptr,
Soory, I not understand, why lose the optlink ?
Read the libs is simple, but, the linker do the brute force!
On Monday, 14 July 2014 at 15:17:06 UTC, Jason King wrote:
On Monday, 14 July 2014 at 14:50:36 UTC, Alexandre wrote:
Yes yes, I did it, I used the anonymous type
Look the complete code:
On Monday, 14 July 2014 at 14:50:36 UTC, Alexandre wrote:
Yes yes, I did it, I used the anonymous type
Look the complete code:
https://gist.github.com/bencz/3576dfc8a217a34c05a9
I know, has several things that can be improved
Now that you've done that, can you build us a linker that reads
Yes yes, I did it, I used the anonymous type
Look the complete code:
https://gist.github.com/bencz/3576dfc8a217a34c05a9
I know, has several things that can be improved
Is there a way to take an interface and implement it generically?
e.g., All functions are implemented either as throw and/or return
defaults and properties are implemented as getter/setters.
This is for mocking up so I a simple way to create a class based
off only the interface.
Essentially
Generally in D field names start with a lowercase (unless you
need them with uppercase).
And user defined type names start with an upper case. This is
useful, because if you write:
scth[0].Misc.virtualSize = 15;
You see immediately that Misc is not a value but a type. So it
can't work.
By
Alexandre:
BYTE[8] Name;
Generally in D field names start with a lowercase (unless you
need them with uppercase).
Btw, my problem is, how to acess the union elements ?
I try this:
//...
scth[0].Misc.VirtualSize = 15;
//...
But, the compiler return that error:
main.d(151)
bearophile, Thanks for all help!
As I said, I'm coming from C # and C + +, I need to learn
"tricks" of D language...
'm reading this book: http://ddili.org/ders/d.en/
I have a struct with union...
struct IMAGE_SECTION_HEADER
{
BYTE[8] Name;
union Misc
{
Hi,
I am porting C++ code that undo "Object Slicing" by casting
const-references:
http://en.wikipedia.org/wiki/Object_slicing
My translation in D Code
struct A
{
// stuff
}
struct B
{
A a;
alias a this;
// stuff
}
void myFunction(ref const(A) a)
{
if ()
{
// here
On 07/14/14 13:42, Philippe Sigaud via Digitalmars-d-learn wrote:
> asserts get an entire copy of the parse tree. It's a bit wasteful, but
> using 'immutable' directly does not work here, but this is OK:
>
> enum res = MyRegex("abcabcdefFOOBAR"); // compile-time parsing
> immutable result
Alexandre:
I get a lot of problens, to convert 'strings' to UCHAR... :/
I suggest you to take a look at the D docs and understand what D
fixed-sized arrays are, dynamic arrays, and strings (that are
dynamic arrays).
Bye,
bearophile
Andrea Fontana:
Is there any counter-indication with this:
immutable ubyte[5] stub = x"b8 01 4c cd 21".representation;
?
See:
https://issues.dlang.org/show_bug.cgi?id=10454
https://issues.dlang.org/show_bug.cgi?id=5909
Is it a compile time value?
Generally you need module-level values o
immutable ubyte[5] stub = x"b8 01 4c cd 21".representation;
that is a Real-Mode Stub Program
On Monday, 14 July 2014 at 12:32:38 UTC, Andrea Fontana wrote:
Is there any counter-indication with this:
immutable ubyte[5] stub = x"b8 01 4c cd 21".representation;
?
Is it a compile time value?
On Sunday, 13 July 2014 at 17:24:40 UTC, Timon Gehr wrote:
but separate-line opening braces definitely make it easier
to see where scopes begin and end.
This is the only argument I have heard in favour of doing this,
but it is not actually valid. This critique might apply to Lisp
style.
It
I don't see much need for such aliases.
Ok, how I can reduce the number of aliaSs ?
I suggest to avoid magic constants like that 0x80, like I have
avoided it here:
memcpy(&image[IMAGE_DOS_HEADER.sizeof],
Btw, I need to start that part of code in x80
Look, that is my C++ code base: http://d
Is there any counter-indication with this:
immutable ubyte[5] stub = x"b8 01 4c cd 21".representation;
?
Is it a compile time value?
On Monday, 14 July 2014 at 12:18:20 UTC, bearophile wrote:
Alexandre:
Look at line 114 of my code: http://dpaste.com/3B5WYGV
The indentations are messed up
On Sunday, 13 July 2014 at 16:10:31 UTC, Gary Willoughby wrote:
Here is the 'official' style that is followed by most people
including me.
http://dlang.org/dstyle.html
Unrelated to my original question. I already read that before
asking.
Alexandre:
Look at line 114 of my code: http://dpaste.com/3B5WYGV
The indentations are messed up.
peh.Signature = ('\0' << 8) + ('\0' << 8) + ('E' << 8) + 'P';
You need shifts 8, 16, 24...
alias PIMAGE_DOS_HEADER = IMAGE_DOS_HEADER*;
I don't see much need for such aliases.
On Monday, 14 July 2014 at 11:28:15 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:
Halas, that's not what the OP wants. He needs properties on the
*type*
itself: int.foo instead of foo!int.
Yes, exactly.
So no, this is not possible.
Hmm.
So how do I use stuff like this:
template
And some other strange thing is, the generate struct in PE file
is wrong.. look at imagens...
As it should be...: http://i.imgur.com/4z1T3jF.png
And how is being generated...: http://i.imgur.com/Oysokuh.png
My actual source is that: http://dpaste.com/2TZKWF5
On Monday, 14 July 2014 at 11:55:1
Look at line 114 of my code: http://dpaste.com/3B5WYGV
Have a more better way to make this conversion ?
*(DWORD*)"PE\0\0" ?
> 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?
You can try Pegged, a parser generator
Halas, that's not what the OP wants. He needs properties on the *type*
itself: int.foo instead of foo!int.
So no, this is not possible.
On Monday, 14 July 2014 at 10:28:30 UTC, Dominikus Dittes Scherkl
wrote:
Is it possible to write custom properties for basic types, so
that I can write e.g. "int.myProp" instead of "myProp!int()"
[analogue to x.myProp instead of myProp(x)]?
yes, just define a funciton with the first parameter
On Sunday, 13 July 2014 at 07:18:38 UTC, Jason King wrote:
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 erro
Is it possible to write custom properties for basic types, so
that I can write e.g. "int.myProp" instead of "myProp!int()"
[analogue to x.myProp instead of myProp(x)]?
Ola Fosheim Grøstad:
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?
Compiler simplicity and to avoid flow analysis. The value range
is kept acr
71 matches
Mail list logo