How Can I Print Raw Binary Into The Console?
I Have Variable Of Type ubyte which equals 0b011 How Can I Get
The Variable To Print Out As 011
On 07/11/2014 10:56 PM, Sean Campbell wrote:
How Can I Print Raw Binary Into The Console?
Taking a step back, a D program prints to stdout, not console. However,
in most cases a D program's output ends up on the console when it is
started in a console.
So, one can print any byte value to
In case you have missed the thread:
http://www.reddit.com/r/programming/comments/2ag8qe/the_constness_problem/
Bye,
bearophile
The Subject says it all, is something like psutils available in
D? [1]
I need it to measure memory usage of a process.
[1] https://github.com/giampaolo/psutil
thank you
Thomas
I also need to get the user and system time of a process, doesn't
seem to be available in Phobos. (e.g. getrusage in Linux but
platform independent)
On Friday, 11 July 2014 at 16:22:37 UTC, anonymous wrote:
There's http://dlang.org/phobos/std_traits.html#hasIndirections
Thx.
I've created a simple stack type using calloc/free which seems to
work nicely. Then instead of using C functions i've tried to
implement the same type using the GC. However i'm experiencing a
crash. I've been staring at this snippet for hours now any help
would be appreciated. This is a
On 12.07.2014 16:24, anonymous wrote:
No explanation or solution, but a reduction:
import core.memory;
void main()
{
alias T = ubyte;
enum size1 = 2_049; /* 2_048 = 2^^11 */
enum size2 = 1_048_577; /* 1_048_576 = 2^^20 */
T* _data;
_data =
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.dlang.org/show_bug.cgi?id=13111
Ive been reading the OSX notes for the DMD compiler but not
everything is clear to me as i dont know how exactly the compiler
looks for things.
i wanted to test it out first using this package from
code.dlang.org
http://code.dlang.org/packages/colorize
I downloaded the zip, extracted it, and
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 coding style of my
library and I get accustomed to use braces on
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[]) * a;
a.some_var = hello;
}
}
void main()
{
c = new myclass();
c.MYfunction();
}
This leads to a
Also, (*c).MYfunction() is leading to segmentation fault
sorry, I meant (*a).some_var
not (*c).MYfunction()
On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string,
On Saturday, 12 July 2014 at 19:19:28 UTC, seany wrote:
For reasons further down in the software, I need to do this
with a pointer. How do I do it with a pointer, please?
I don't know what are you trying to achieve, but if that's what
you want, you can do:
void MYfunction()
{
auto
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those which
are known at a given moment?
On 07/12/2014 12:19 PM, seany wrote:
On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
arc!(string, string[]) * a;
a.some_var = hello;
a has not been instantiated. You are declaring it as a pointer to
struct and
On 07/12/2014 12:32 PM, seany wrote:
do I have to initialize all variables of the struct?
No. The uninitialized ones get their .init values.
or may I also use a
this(){} in the struct and initialize only those which are known at a
given moment?
That already works with structs. You don't
On Saturday, 12 July 2014 at 19:01:56 UTC, Danyal Zia wrote:
Should I worry about it? Or is that's just a debatable style
that won't really matter if it's persistent throughout library?
Depends entirely on whenever you want to match style of standard
library - no one will blame you for having
On Saturday, 12 July 2014 at 19:32:48 UTC, seany wrote:
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those
which are known at a given moment?
You can initialize in constructor this(), but you can't
initialize partial
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
On 07/12/2014 12:38 PM, Danyal Zia wrote:
You can initialize in constructor this(), but you can't initialize
partial fields of struct when using pointer to struct.
Actually, that works too but members must be initialized from the
beginning. The trailing ones are left with .init values:
On Saturday, 12 July 2014 at 19:42:13 UTC, Ali Çehreli wrote:
Actually, that works too but members must be initialized from
the beginning. The trailing ones are left with .init values:
struct S
{
int i;
string s;
}
void main()
{
auto s = new S(42);
static assert(is (typeof(s)
On Saturday, 12 July 2014 at 19:35:11 UTC, anonymous wrote:
There is another stylistic choice which I do find confusing:
capitalized identifiers for non-types, e.g. variables and
functions. Please don't do that.
Agreed about variables and functions. However I personally prefer
to use
I got to typing one day and came up with this. What it does is
search an aggregate for a member named match. If it's a direct
member, it evaluates to that. If it's not, then it searches any
aggregate type sub-members (deep members) for match. If there's
only one deep member tree with match, it
One way I've used it in code
struct MapBy(T,string key) if (hasDeepMember!(T,key)) {
alias key_t = DeepMemberType!(T,key);
private const(T)[key_t] _map;
bool has(key_t id) const nothrow {
if ((id in _map) != null) return true;
else return
On 07/10/2014 09:05 AM, Alexandre wrote:
I have a string X and I need to insert a char in that string...
auto X = 100;
And I need to inser a ',' in position 3 of this string..., I try to use
the array.insertInPlace, but, not work...
I try this:
auto X = 100;
auto N =
On Saturday, 12 July 2014 at 08:34:41 UTC, Thomas Mader wrote:
The Subject says it all, is something like psutils available in
D?
would psutils itself be acceptable?
https://bitbucket.org/ariovistus/pyd
.
try:
unittest {
Velocity v = new Velocity( 2.0f, 5.0f );
v *= 5.0f; // - line 110
printf( v = %s\n, to!string(v) );
}
instead. Basically version is like static if, it doesn't
indicate its a function. Instead it changes what code gets
compiled.
Where as a unittest
On 13/07/2014 2:35 p.m., dysmondad wrote:
.
try:
unittest {
Velocity v = new Velocity( 2.0f, 5.0f );
v *= 5.0f; // - line 110
printf( v = %s\n, to!string(v) );
}
instead. Basically version is like static if, it doesn't indicate its
a function. Instead it changes what
On Sun, Jul 13, 2014 at 02:35:11AM +, dysmondad via Digitalmars-d-learn
wrote:
[...]
So, what is the generally accepted way include unit testing? TDD is
all the rage these days and I though I would try my hand at it as well
as D.
Just include unittest blocks in your program and compile
On Sun, Jul 13, 2014 at 02:39:00AM +, dysmondad via Digitalmars-d-learn
wrote:
On Saturday, 12 July 2014 at 05:23:29 UTC, Ali Çehreli wrote:
On 07/11/2014 10:08 PM, dysmondad wrote:
class Velocity
{
[...]
ref Velocity opOpAssign(string op) ( in float multiplier
)
...
https://github.com/rikkimax/skeleton/blob/master/source/skeleton/syntax/download_mkdir.d#L175
Of course there will be better ones, just something I was doing
last night however.
Thanks for the link and the information.
That's looks like what I need so I'm going to rip off your code
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
On 07/12/2014 08:37 PM, H. S. Teoh via Digitalmars-d-learn wrote:
ref makes it possible for the caller to modify the pointer returned by
the callee. For example:
class D { int x; }
class C {
D d;
this(D _d) { d = _d; }
ref D getPtr() { return d; }
On Sat, Jul 12, 2014 at 09:30:44PM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
On Sat, Jul 12, 2014 at 09:20:06PM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
The twist here is that the OP's function returned 'this' by
reference. Changing that not only not have any effect
On Sunday, 13 July 2014 at 01:53:10 UTC, Mike Parker wrote:
On 7/13/2014 3:54 AM, Israel Rodriguez wrote:
The linker errors do not refer to libcolorize. Notice this:
_D4dlib4math6matrix. That is a dlib.math.matrix module. Is
that a source module in your project or something from another
38 matches
Mail list logo