Re: a "success story for D" ! !!

2015-05-06 Thread d coder via Digitalmars-d
>
>
> This is great going, Puneet. Congratulations, good luck, and keep us all
> posted! -- Andrei
>

Thanks Andrei.

And thanks again to Walter, yourself, Kenji and other developers who
together made D a wonderful language.


Re: a "success story for D" ! !!

2015-05-06 Thread d coder via Digitalmars-d
Unlike mainstream software, it requires a lot of effort to get hardware
> guys interested in software.
>

I meant to say "interested in *opensource* software"


Re: a "success story for D" ! !!

2015-05-06 Thread d coder via Digitalmars-d
Greetings


> half the site is 404, the github account show little activity and
> information pretty sparse. smells kinda dubios..
>

I am really sorry for the poor webpage. We are actively working on that
front, but progress is slow since we need to give priority to customer
projects. We are an unfunded startup in India and provide chip verification
services for surviving.

Unlike mainstream software, it requires a lot of effort to get hardware
guys interested in software. But we believe (and have demonstrated) that
Vlang has certain advantages over commercial chip verification languages.
And we continue to develop it further to gain more advantage. We expect to
push in more code into Github once DMD 2.068 gets released.

- Puneet


Re: a "success story for D" ! !!

2015-05-06 Thread d coder via Digitalmars-d
> But, a fair chunk of code. Maybe there's little activity recently because
> they consider it done. I haven't committed to the majority of my github
> things for months, but I still stand by them.
>

Greetings

I am the lead developer of Vlang.

Vlang is still being actively worked on. We are not pushing in more recent
code into Github since the code requires Github HEAD version of DMD to
compile. We are using some metaprogramming features that are available only
with the development version of DMD.

Regards
- Puneet


Bug with nested static class referencing?

2015-01-18 Thread d coder via Digitalmars-d
Greetings

I hit what looks like a probable DMD bug. When I reduced with help from
dustmite I get something like this. Can someone tell me if this is a bug or
am I doing something illegal?

class A {
  B.BB b;
}

class B: A {
  static class BB {}
}

When I compile I get:

test.d(2): Error: no property 'BB' for type 'test.B'
test.d(2): Error: B.BB is used as a type

Regards
- Puneet


Why this UDP will not compile?

2014-09-27 Thread d coder via Digitalmars-d
DMD wont compile this. I get an error saying:
/tmp/test.d(3): Error: need 'this' for 'foo' of type 'int'
Failed: ["dmd", "-v", "-o-", "/tmp/test.d", "-I/tmp"]

Is this a bug or is it illegal code?

// Regards
// Cherry

class Foo {
  int foo = 42;
  @foo int bar;
  this(int frop) {
foo = frop;
  }
  int getFooAttr() {
auto  = __traits(getAttributes, this.tupleof[1]);
return [0];
  }
}

void main() {
  Foo f = new Foo(43);
  f.getFooAttr();
}


Re: Member function pointers

2014-05-27 Thread d coder via Digitalmars-d
https://github.com/D-Programming-Language/dmd/pull/3181

Daniel asked me to use this. And it works.

Use something like:

union U
{
  void delegate(int) dg;
  struct
  {
void* ptr;
void function(int) funcptr;
  }
}
U u;
u.dg = dg;
u.funcptr = ...;
u.ptr = ...;

Regards
- Puneet


Re: Member function pointers

2014-05-27 Thread d coder via Digitalmars-d
On Mon, Jun 10, 2013 at 10:13 PM, Jacob Carlborg  wrote:

> On 2013-06-10 18:34, Manu wrote:
>
>> On 11 June 2013 02:26, Jacob Carlborg mailto:d...@me.com>>
>>
>> wrote:
>>
>> On 2013-06-10 17:40, David Nadlinger wrote:
>>
>> Let me try to summarize it in code:
>>
>> ---
>> class A { void foo(); }
>> auto memberFun = (&A.foo).funcptr;
>>
>> auto a = new A;
>> memberFun(a);
>> ---
>>
>>
>> Why is this better than a delegate?
>>
>>
>> It's not 'better', it's different.
>>
>
> class A { void foo(); }
> auto memberFun = (&A.foo).funcptr;
>
> auto a = new A;
> void delegate () dg;
> dg.funcptr = memberFun;
> dg.ptr = cast(void*) a;
> dg();
>
> The details can be hidden in a function call. Sure, a delegate could be
> type safe but still don't see the point.
>
> --
> /Jacob Carlborg
>

Greetings

Apologies for bringing up this year old thread.

With https://github.com/D-Programming-Language/dmd/pull/3181 getting
merged, it is no longer feasible to directly assign dg.funcptr (which is
not an lvalue now). The problem is that the code suggested by David also
does not work.

Is there an alternative?

Regards
- Puneet


Re: Test

2013-10-13 Thread d coder
On Sun, Oct 13, 2013 at 9:56 PM, Iain Buclaw  wrote:

> I don't think I'm receiving emails from this ML. Is anyone else seeing
> this?


I generally use mailing list interface and I am seeing your post on mailing
list.


Re: DConf 2013 last talk

2013-10-13 Thread d coder
On Sat, May 4, 2013 at 12:41 AM, Rob T  wrote:

> I have significantly reduced CG performance issues (up to 3x faster) with
> strategically placed disabling and enabling of the GC, so it may be that
> the problem can be solved using carefully placed GC.disable and GC.enable
> calls at points in the compilation process. This is not the best solution,
> but it could be a quick temporary fix until the GC problem is dealt with
> directly.


Hello Rob

I am totally stuck with my compile time parsing memory issues at this
point. I have 8GB RAM on my machine and the compiler goes out of memory
even when parsing a small block. So I am re-opening this old thread. Is it
possible for you to share your work with me so that I can experiment a
little bit.

Thanks and Regards
- Puneet


Re: Using emplace leading to memory corruption

2013-09-29 Thread d coder
> I tried that and it still crashes. I don't think that's the problem.
> Puneet, the code looks legit, please file a bug report.


Thanks for confirming.

 http://d.puremagic.com/issues/show_bug.cgi?id=11139

Regards
- Puneet


Using emplace leading to memory corruption

2013-09-29 Thread d coder
Greetings

I am trying to use emplace and it is seemingly leading to memory
corruption. Before I file a bug on DMD Buzilla, I want to find out if I am
doing something wrong or if it is a known issue. I am using a linux box and
this testcase is freaky -- if I comment out either line 20 or line 24, the
segfault vanishes.

Thanks
- Puneet

$ rdmd --force -version=EMPLACE -Isrc -J.. test.d
4000
Segmentation fault (core dumped)
$ rdmd --force -Isrc -J.. test.d
4000

struct bdd {}  // 01
class Frop {   // 02
  int[] _var;  // 03
  int[] var() {// 04
return _var;   // 05
  }// 06
  this() { // 07
this._var.length = 1;  // 08
  }// 09
}  // 10
class Foo {// 11
  long[] nodes;// 12
  Frop[] frops;// 13
  long[] table;// 14
  this() { // 15
nodes.length = 12; // 16
frops.length = 1;  // 17
frops[0] = new Frop(); // 18
initTable();   // 19
zoo(frops[0].var); // 20
  }// 21
  void initTable() {   // 22
import std.stdio;  // 23
writeln(4000); // 24
table.length = 4;  // 25
  }// 26
  void zoo(int[] varset) {}// 27
}  // 28
class Bar {// 29
  Foo _foo;// 30
  this() { // 31
version(EMPLACE) { // 32
  import std.conv, core.stdc.stdlib;   // 33
  enum size_t size = __traits(classInstanceSize, Foo); // 34
  assert(size is 32);  // 35
  void* tmp = core.stdc.stdlib.malloc(size);   // 36
  if (!tmp)// 37
throw new Exception("Memory allocation failed");   // 38
  void[] mem = tmp[0..size];   // 39
  _foo = emplace!(Foo)(mem);   // 40
}  // 41
else { // 42
  _foo = new Foo();// 43
}  // 44
  }// 45
}  // 46
void main() {  // 47
  auto bar = new Bar;  // 48
}  // 49


Re: UFCS requires explicit this

2013-05-04 Thread d coder
Timon, you mean such support is planned, or is the current behavior the
expected behavior.

Regards
- Puneet



On Sat, May 4, 2013 at 4:57 PM, Timon Gehr  wrote:

> This is to be expected.
>


UFCS requires explicit this

2013-05-04 Thread d coder
Greetings

Consider the following code ...

class Foo { // 1
  void foo() { // 2
bar(); // 3
this.bar(); // 4
  } // 5
} // 6
void bar(Foo f) { // 7
  import std.stdio; // 8
  writeln("This bar"); // 9
} // 10
void main() { // 11
  Foo test = new Foo; // 12
  test.foo(); // 13
} // 14

DMD is fine with line 4 because of UCFS. But it gives an error for line 3
because it does not get this pointer to bind as argument.

I want to know if it is a DMD bug or whether line 3 would be compilable at
some point in future.

Regards
- Puneet


Re: DConf 2013 last talk

2013-05-02 Thread d coder
On Fri, May 3, 2013 at 5:41 AM, Joseph Cassman  wrote:

> If you could provide an update on the allocators design and implementation
> -- progress and/or roadmap -- that would be great. Also if there are any
> plans to update std.container as a result.
>

+1

And another one. I am working on an embedded DSL on top of D Language. I am
using compile time parser ctpg https://github.com/youkei/ctpg for some
syntax parsing. It works great, expect for memory footprint of the compiler
which makes it impractical to parse any 1000+ lines of code at compile time.

So the question is -- What are the plans to optimize the compiler from
memory perspective? I know that the GC is disabled at compile time to make
the compiler as fast as possible. Can we think about adding a switch to dmd
to optionally enable the GC? This is not going to change the
functional behavior of the compiler and so we can give an option to the
end-user to enable the switch when compile time footprint is becoming an
issue.

Regards
- Puneet


GDB support for multithreaded D application debugging

2013-04-29 Thread d coder
Greetings

I just wanted to find out how good is the GDB support for debugging
multithreaded code written in D language. I remember trying it sometimes
back, but could not get it to work.

Any suggestions?

Regards
- Puneet


Trait for listing symbols in a delegate's closure?

2013-04-28 Thread d coder
Greetings

I am wondering if there is a way to find out a tuple of all the
symbols/identifiers in a given delegates closure.

Regards
- Puneet


Re: Customized @safe like semantics for user attributes?

2013-03-15 Thread d coder
> There could be other possibilities as well, like a function without @foo
> attribute not being able to call a function with the attribute in its body.
>
>
I mean, a function without @foo should not be able to call a function with
@foo attribute.


Re: C++ guys hate static_if?

2013-03-09 Thread d coder
Greetings

I believe the paper takes a contrived route to criticize "static if". It
takes some bad code examples which are not obvious use cases of "static if"
and then goes on to say that the resultant code is not good. I think the
code example to begin with was not good.

Regards
- Puneet


Re: D is coming to a town near you

2013-02-20 Thread d coder
On Thu, Feb 21, 2013 at 12:27 AM, H. S. Teoh  wrote:
> But once I get into the realm of new features introduced in D, like
> generic metaprogramming, functional-style code, non-trivial range APIs,
> const-correctness, purity, etc., I just keep running into bugs,
> unexpected interactions, conflicting designs, etc.. It can be quite
> frustrating at times. No doubt, a lot of stuff *does* work, but bugs /
> design issues are also quite frequent, which detracts a lot from one's
> experience of D.
>
> Sometimes I wonder if we're over-stretching ourselves with the amount of
> clever features in D, as Kernighan once said:
>
> Debugging is twice as hard as writing the code in the first
> place. Therefore, if you write the code as cleverly as possible,
> you are, by definition, not smart enough to debug it. -- Brian
> W. Kernighan
>
> Maybe D already has enough innovations, and now is the time to revisit
> what is already there and polish it up into the refined product that it
> should be.

On that measure, the present state of D is goof. When I try something
clever in metaprogramming for example, I generally hit a wall. Then I
think again and usually I get a much simpler way and the D compiler
too is happy with that.

In a way the buggy facet of D compiler is helping me :-)


Re: D is coming to a town near you

2013-02-20 Thread d coder
Cool I will try not to sleep when I catch a train next time. :-)


Re: Why does this extremely simple operation not work?

2013-02-12 Thread d coder
In D, class objects are implicitly pointers. So try the following code.

class Parent {}
class Child : Parent {}

void myFunc(Parent obj) {
  import std.stdio;
  writeln("got ", obj);
}

void main() {
  Child myChild = new Child();
  myFunc(myChild);
}


pass-by-ref semantics for structs (was Deque impl.)

2013-01-31 Thread d coder
On Thu, Jan 31, 2013 at 5:30 PM, monarch_dodra  wrote:
> The pull is kind of stuck in limbo, specifically because of the problems
> associated with implementing reference semantics with structs :/


Thanks for the enlightening email.

I am of the considered view that reference semantics with structs in D
is tough (if not impossible) with default constructor and postblit
constructor (used when passing objects). This is because you can not
initialize any object (wrapped in the struct) in the default
constructor and if you are passing the struct as a function parameter,
it is not possible to initialize these internal objects (before
passing them) in the postblit constructor. I faced this in some of my
code. Do not know if you are facing the same scenario in the DList
implementation.

Are there any possible solutions in the pipe?

Regards
- Puneet


Re: Deque impl.

2013-01-31 Thread d coder
On Thu, Jan 31, 2013 at 2:43 PM, Robert burner Schadek
 wrote:
> Thats not totally correct. The Rb tree is a class. But the real reason for
> the Deque being a class
> is that it holds two value members. And if you pass the Deque around you
> need to do this as ref.
> Otherwise you shall not call any method that modifies this value members,
> because this will only be
> visible at the calling site.

I would expect all the containers in the std.container to have either
pass by value or pass by reference semantics. It seems at least Array,
Slist, and Dlist are structs and they follow pass by value semantics.

>From Dlang.org:

auto a = DList!int([3, 4]); //Create a new chain
auto b = a; //Point to the same chain
// (3 - 4)
assert(a[].equal([3, 4]));
assert(b[].equal([3, 4]));

b.stableInsertFront(1); //insert before of b
b.stableInsertBack(5); //insert after of b
// (2 - (3 - 4) - 5)
assert(a[].equal([3, 4])); //a is not changed
assert(b[].equal([1, 3, 4, 5])); // but b is changed


Regards
- Puneet


Re: Deque impl.

2013-01-30 Thread d coder
> To be honest deque can be implemented far better if random access as in
> indexing, removal and such is dropped.

As other people too pointed out, Deque is indeed a random access
range, so indexing operator is a must. Insert/Remove too are good to
have. Array implementation in the std.container too implements remove
and insert.

Another small issue is that this Deque implementation is a Class.
std.container provides all the containers as structs. So for sake of
consistency, we should implement Deque too as a struct.

Regards
- Puneet


Re: D popularity

2013-01-20 Thread d coder
On Sun, Jan 20, 2013 at 6:21 PM, David  wrote:

> I am not using the forum, but still sending messages. You can send
> messages directly via a NNTP client, you don't have to use the forum, so
> it's definitly possible he doesn't know of it.
>

David, that can be guessed on basis of the email headers. And the OP does
appear to have used dlang forum.

Regards
- Puneet


Re: Accessing UDA of private field

2013-01-06 Thread d coder
> You can use a string mixin:
>
> class Foo
> {
> int a;
> @(3) private int b;
> }
>
> void main()
> {
> writeln(mixin("__traits(getAttributes, " ~ Foo.tupleof[1].stringof ~
> ")")); // -> 3
> }
>
>
>

Hmm

This works only when main is in the same file (and therefor module) as Foo.

Regards
- Puneet


Is this a known issue in Phobos/DMD?

2013-01-05 Thread d coder
Greetings

When I compile the code below, I unexpectedly get an error:
test.d(7): Error: template std.string.format does not match any function
template declaration. Candidates are:
/home/puneet/local/github-d/bin/../phobos/std/string.d(2528):
 std.string.format(Char, Args...)(in Char[] fmt, Args args)
test.d(7): Error: template std.string.format(Char, Args...)(in Char[] fmt,
Args args) cannot deduce template function from argument types
!()(string,void)

There are a couple of issues involved here.
1. std.string is exposing "count" (and some other functions) from
std.algorithm. I think this should be a bug since count is not listed as a
method in the std.string documentation.
2. Now the function from std.algorithm that becomes visible, shadows the
local argument count. Is this expected behavior? If not, has it already
been reported as a bug? At the minimum I expect better error message here.

Thanks and Regards
- Puneet


void main() {   // 1
  foo(4);   // 2
}   // 3
// 4
void foo(int count) {   // 5
  import std.string;// 6
  format("%s", count);  // 7
}   // 8


Re: struct : implicit conversion for function call arguments

2013-01-01 Thread d coder
> That's not how you define implicit conversions in D. It's a weird hack
> from C++.
>
>
Thanks for clarification. I knew about alias this, but I thought it was in
addition to constructor path.

Regards
- Puneet


Re: DList -- removing an element

2012-12-30 Thread d coder
Thanks Jonathan.


DList -- removing an element

2012-12-30 Thread d coder
Greetings

I have created a DList of class objects. Now I want to delete a particular
object from the list. I do not see a straightforward way of doing that. The
only way I found was to create a DList range, take out all other elements
from the range using popFront and popBack and then apply remove(Range).

Am I missing something?

Regards
- Puneet


Re: add phobos module std.halffloat ?

2012-12-19 Thread d coder
On Wed, Dec 19, 2012 at 3:43 PM, Iain Buclaw  wrote:

> How difficult would you think it would be to scale down (or up) this
> library type so it can be an emulated IEEE type of any size? (The whole
> shebang eg: quarter, half, single, double, quad, double-quad, 80bit and
> 96-bit).   Just interested as I think that a module which implements an
> IEEE floating point type that produces constant results cross-platform
> would be better than a dedicated module just for half float types.
>


+1


Re: UDA: getAttributes does not play well with topleof

2012-12-18 Thread d coder
Greetings

I thought I would be able to use allMembers/getMembers traits to access the
attributes of all the members of a class. But that fails me if some members
of the class are private.

Consider the code pasted below -- I get en error:

B.d(5): Error: class A.Foo member bar is not accessible

And so it seems it is essential that tupleof works with getAttributes,
since tupleof does not care for access protection.

I have filed a bug on Budzilla.
http://d.puremagic.com/issues/show_bug.cgi?id=9178

Regards
- Puneet

module A;
enum Boo;
class Foo {
  private @Boo int bar;
}

module B;
void main() {
  import A;
  Foo foo = new Foo;
  static if(__traits(getProtection, __traits(getMember, foo, "bar"))  //
<-- can not access foo.bar
== "public")
{
  // Check for attribute Boo and proceed
}
}


Re: UDA: getAttributes does not play well with topleof

2012-12-17 Thread d coder
On Mon, Dec 17, 2012 at 9:56 PM, Walter Bright
wrote:

> On 12/17/2012 3:55 AM, d coder wrote:
>
>> So my question is: Is this a bug in DMD, or am I doing something plainly
>> wrong?
>>
>
> You're doing something wrong. Consider:
>
> @Bar int i = 3;
> int x = i;
>
> The UDA does not get transferred to x. This is why your loop:
>
> foreach(ref l; foo.tupleof)
>
> does not transfer the UDAs to l.
>
>
But Walter, even the code below does not work.
Error: first argument is not a symbol
tuple(false)


template Tuple(T...) {
  alias T Tuple;
}

enum Bar;
class Foo {
  @Bar int a;
}

void main()
{
  Foo foo = new Foo;
  alias Tuple!(__traits(getAttributes, foo.tupleof[0])) tp;
  pragma(msg, tp);
}


Re: UDA: getAttributes does not play well with topleof

2012-12-17 Thread d coder
> Try something like this:
>
> foreach (i, dummy; foo.tupleof)
> {
> alias Tuple!(__traits(getAttributes, foo.tupleof[i])) tp;
> pragma(msg, tp);
> }
>
>
Ok so that is because ref does not work with foreach on tuples. Somehow I
thought that got fixed.
Anyways, with your suggestion I get a strange error.

Error: first argument is not a symbol
tuple(false)

Regards
- Puneet


Re: UDA: getAttributes does not play well with topleof

2012-12-17 Thread d coder
Ok. It seems to work with allMembers/getMember traits combination.

But should it work with tupleof or not?

Regards
- Puneet


Re: Should alias this support implicit construction in function calls and return statements?

2012-12-13 Thread d coder
I do not know if I am missing something but consider:

struct Foo {
  int r;
  int i;
  bool get() {
return true;  // always return true
  }
  alias get this;
}

So I am wondering how it would be possible to construct Foo from a bool?
Otherwise how would the compiler be able to figure out in what scenarios
reverse conversion is possible and is intended.

Regards
- Puneet


Re: Nested Structs (Solution)

2012-12-12 Thread d coder
> The name doesn't matter. I just wanted to annoy Walter again with yet
>> another bit of evidence that completeness of a feature is important even if
>> it doesn't seem to have an obvious use case. People will do what is logical
>> and end up with hacks like that.
>>
>
I believe it *is* an obvious use case. In D we use structs when we want to
save on memory. And creating a class environment to encapsulate a system of
structs is an obvious use case. In fact I am in this situation and thanks
to your hack, I will try to use it for the time being.


>
>>  Little would have to be done to the structs to make it work. In fact,
>>> the method should work if D ever decides to support such a feature with
>>> little change. Compile times could be increased though by removing the
>>> templating, but unfortunately that might require a lot of work. A mixin
>>> might simplify it.
>>>
>>
> Ok, maybe thats why my posts have not received any attention except by you
> ;)


Let us trend it ;-)

Regards
- Puneet


Re: OT (partially): about promotion of integers

2012-12-11 Thread d coder
On Wed, Dec 12, 2012 at 8:14 AM, Walter Bright
wrote:

> (This is how the high level vector library Manu is implementing is done.)
>

Greetings

Where can I learn more about this library Manu is developing?

regards
- Puneet


Re: Is there any reason why arithmetic operation on shorts and bytes return int?

2012-12-11 Thread d coder
On Wed, Dec 12, 2012 at 3:40 AM, Walter Bright
wrote:

> No worries there :-) I feel pretty dang strongly about this issue, from
> bad experience.
>
> Even if a language behaves "wrong", it is still usable if it is
> predictable.
>

Agreed.

How about this.

1. Let "char" and "short" behave the C/C++ way. These can return integers.
This will make C/C++ code work in D.
2. Make D "byte" operations return bytes. And create another type (named
say dbyte or shortint) and make operations on the new type return
shortints. This will make these types more usable in D code. Well we end up
adding another keyword, but we shall get workable and safe 8-bit and 16-bit
integrals.

Regards
- Puneet


Re: Is there any reason why arithmetic operation on shorts and bytes return int?

2012-12-11 Thread d coder
Thanks Everybody for responding. I have another query which is off-topic
but related.

Why is the following allowed in D?

long a;
int b;

b += a; // Allowed -- no explicit cast
b = a + b; // Not allowed
b = a;  // Not allowed


Re: Is there any reason why arithmetic operation on shorts and bytes return int?

2012-12-11 Thread d coder
On Tue, Dec 11, 2012 at 7:05 PM, Peter Alexander <
peter.alexander...@gmail.com> wrote:

> That's the whole point. What you are doing is dangerous, so it requires
> the cast.
>


What I am doing is not dangerous. I am operating at byte/short level.
Tell me, if what I am doing is dangerous, how come doing the following is
not dangerous. It is allowed by D.

int a, b, c;
a = b + c;

Also the sense of safety that you get for short and byte too is not
complete. Consider:

void main() {
  import std.stdio;
  ushort a = ushort.max;
  ushort b = ushort.max;
  a += b;
  writeln(a);
}


Is it too much to ask for consistent behavior across the built-in types?

Regards
- Puneet


Re: Is there any reason why arithmetic operation on shorts and bytes return int?

2012-12-11 Thread d coder
On Tue, Dec 11, 2012 at 6:23 PM, monarch_dodra wrote:

> D's stance regarding integer operations is "if it compiles, it creates the
> same output as in C".
>

Thanks Monarch. So it is a gotcha we inherit from C. :-)

Regards
- Puneet


Re: Is there any reason why arithmetic operation on shorts and bytes return int?

2012-12-11 Thread d coder
For some more clarity, when I compile the following code:

void main() {
  import std.stdio;
  byte a;
  byte b;
  byte c = a + b;
}

I get error:
test.d(6): Error: cannot implicitly convert expression (cast(int)a +
cast(int)b) of type int to byte

Why is D trying to convert bytes and shorts to integers before applying any
arithmetic operator?

Regards
- Puneet


Is there any reason why arithmetic operation on shorts and bytes return int?

2012-12-11 Thread d coder
Greetings

The following code prints . Similar thing happens when a and b are
bytes.
Is this intended?

Regards
- Puneet

void main()
{
  import std.stdio;
  ushort a = 0x55AA;
  ushort b = 0xAA55;
  writefln("%X", ~(a | b));
}


Re: Need help with debugging Segfault

2012-12-03 Thread d coder
> But it's not a bug. Like Ali said:
>
> The destruction order of GC-maintained resources is not deterministic as
> e.g. in C++. It is quite possible that the member of an object is destroyed
> before the object itself.


Oops. I get it now.

What should be done to avoid this situation? I think I need to add a
destructor for the parent object class that would make sure that such child
objects (that need the parent to be alive during GC process) are destroyed
before the GC process kicks in. Would that be sufficient or would it again
group such GC processes and still keep the sequence indeterminable? In that
case, I will need to introduce a finalize() function which needs to be
called explicitly.

Thanks and Regards
- Puneet


Re: Strange struct/atomicLoad behaviour

2012-11-30 Thread d coder
On Fri, Nov 30, 2012 at 7:41 PM, Maxim Fomin  wrote:

> This is another bug with structures. Consider posting this to bugzilla.
>


Thanks for confirming. I have posted this to Bugzilla.

Regards
- Puneet


Re: Congratulations to the D Team!

2012-07-09 Thread d coder
Congratulations.

I found that my applications still do not compile using the git HEAD.
Waiting eagerly for the 2.060 alpha release.

Regards
- Puneet


Re: D2 Library Porters

2012-07-04 Thread d coder
> Obtain the gdc sources and install into gcc-core (I
> will tarball a copy up that includes the zlib sources too and post a
> link).
>

Greetings

Where would I find the gdc source?

Then rebuild gcc with the same options above above, but with
> --enable-languages=d included.


Would this option enable build for D1 or D2? Are we going to port only D2
(I know D2 is officially named D now)  or both?

Regards
- Puneet


Re: D2 Library Porters

2012-07-03 Thread d coder
>
>
> I'm going to be pushing gdc-4.8 package into debian this weekend (give
> about a fortnight for it to land in sid) - is anyone interested in porting
> Druntime / Phobos over to the architectures that Debian supports?  I can
> give anyone a quick crash course through building a cross compiler if they
> need it.


Hello Iain

I do not know how much I would be able to achieve, but I can contribute a
reasonable amount of time on this.

I would need a crash course though. Let me know how to proceed.

Regards
- Puneet


Re: dmd 2.060 ignoring ref for Array arguments

2012-07-02 Thread d coder
Done.

http://d.puremagic.com/issues/show_bug.cgi?id=8335


dmd 2.060 ignoring ref for Array arguments

2012-07-02 Thread d coder
Greetings

Normally I use released beta versions of dmd, but this time I started using
dmd 2.060 for sake of std.string.xformat.

But I am facing issues. This version is ignoring "ref" when passing array
as ref argument. Kindly see the code below. When I run this code it prints
"Postblit called!" four time.

Regards
- Puneet

//
struct Foo {
  this(this) {
import std.stdio;
writeln("Postblit called!");
  }
}

void barArray(ref Foo[4] _f) { /*do nothing*/ }

void main() {
  Foo [4] fooArray;
  barArray(fooArray);
}


Re: std.string.format results in run-time exception

2012-06-30 Thread d coder
Thanks Kenji, I will use xformat. BTW, why is it named "x"format? Would not
"s"format be a better name? Where "s" could stand for string.

Also I feel, std.string.format should work for BitArray and BigInt too.
Both these types are defined as part of phobos.

Regards
- Puneet


Re: std.string.format results in run-time exception

2012-06-30 Thread d coder
I have files a phobos bug report.

http://d.puremagic.com/issues/show_bug.cgi?id=8326

Regards
- Puneet


std.string.format results in run-time exception

2012-06-30 Thread d coder
Greetings

std.string.format throws runtime exception for BigInt and for BitArray
types even though writefln works fine. The run-time error says
std.format.FormatException@std/format.d(4744): Can't convert
std.bigint.BigInt to string: "string toString()" not defined

Here is a small test case.

Regards
- Puneet

void main()
{
  import std.stdio;
  import std.string;
  import std.bigint;
  import std.bitmanip;

  BigInt aa = 100;

  BitArray bb;
  bb.init([true, false]);

  writefln("%x", aa);
  writefln("%x", bb);
  writeln(format("%x", aa));
  writeln(format("%x", bb));
}


Re: Made a Rage-Comic about D

2012-06-23 Thread d coder
On Sat, Jun 23, 2012 at 10:58 PM, Tobias Pankrath wrote:

> I am currently writing a sat solver for educational purposes


How mature is the sat solver yet? Do you plan to release it at some point
of time?

Regards
- Puneet


Re: LinkedList and Deque API in DCollections

2012-06-21 Thread d coder
>
>
> auto append(T, V)(ref T t, V value)
> {
>  return t.insert(t.begin, value);
> }
>
> should do the trick.
> (you may add a guard to make sure T is a container)
>

Thanks Christophe. I think you are relying on UFCS here.
So cool.

Regards
- Puneet


Re: LinkedList and Deque API in DCollections

2012-06-21 Thread d coder
> Also, I see that "assert(some-expression)" has been used at a lot of
> places in the code of the libraries. Since these libraries are built with
> -release option, should these assert statements not be replaced by
> "enforce"?


Ok I think asserts are fine since these would be taken out and the library
becomes more efficient without these checks. Please ignore.


Regards
- Puneet


Re: LinkedList and Deque API in DCollections

2012-06-21 Thread d coder
>
>
> Did you try : list.insert(list.begin, value);
>

Thanks. But I believe append and prepend are too common use-cases to be
ignored.

Also, I see that "assert(some-expression)" has been used at a lot of places
in the code of the libraries. Since these libraries are built with -release
option, should these assert statements not be replaced by "enforce"?

Regards
- Puneet


LinkedList and Deque API in DCollections

2012-06-21 Thread d coder
Greetings

I do not know if this email belongs to this list or not. It is about a
package available at dsource. Let me know if I should be posting such
emails elsewhere.

I need an implementation of Doubly Linked list and Deque. Since the
std.container library does not support these containers yet, I am trying to
use these from DCollections library available on DSource here
http://www.dsource.org/projects/dcollections . I am using the D2 branch of
this library.

Now the issue is, I could not find any API for adding elements to the
beginning of the LinkList. In the documentation (which is there for D1
version) I see methods like append and prepend, but I do not think these
are implemented in the D2 version of the library. And I see that for Deque,
only prepend is implemented, there is no append.

Also it is not clear to me if the "add" method could be used to append
elements on the back of the LinkList or Deque collection.

Thanks and Regards
- Puneet


Freelists and clear/emplace

2012-06-15 Thread d coder
Greetings

Is emplace/clear  mechanism mature enough to be used to create freelists?

I looked but found very scanty documentation on emplace/clear on dlang.org.

Regards
- Puneet


Re: Calling an alias for a Class method in another scope

2012-06-02 Thread d coder
>
>
> At the moment, the ref-ness of the return type is not determined
> correctly because of a compiler bug. Otherwise, that works mostly
> fine.
>
>
Thank you Max for showing me toDelegate. But I find that it does not work
even for function arguments with default values. So for the moment I will
trod the path Steve showed me.

Regards
- Puneet


DMD does not allow stringof on function alias of a function that takes arguments

2012-06-02 Thread d coder
Greetings All

Using DMD 2.059, the following code does not compile. DMD does not allow me
to apply stringof on a function alias of a function that takes one or more
arguments. It compiles and runs fine for functions that do not take any
arguments.

Is it a bug, or am I doing something wrong here?

Regards
- Puneet

class Foo {
  void foo() { }
  void frop(int n) { }
}

void callfoo(alias F, T) (T t) {
  import std.stdio;
  writeln(F.stringof);
}

void main() {
  Foo f = new Foo();
  callfoo!(Foo.foo)(f); // This works
  callfoo!(Foo.frop)(f); // This does not work
}


Re: Website

2012-06-01 Thread d coder
> Huh, wasn't Digital Daemon the previous site at dlang.org address?
>

No. Digital Daemon is the hosting company that hosts dlang.org as well as
digitalmars.com. Yesterday even digitalmars.com was leading me to Digital
Daemon page. As Walter has said, it was a technical problem with the
hosting.


Re: Calling an alias for a Class method in another scope

2012-06-01 Thread d coder
Steve

One small thing. As you said I might declare a delegate in an alternate
fashion that is by saying "void delegate() dg;".

But would it be possible to rewrite the following declaration in a way that
avoids naming foo explicitly. I would just have an alias for foo. I am
asking this to cover the cases where foo might have a list of arguments and
I want to create a delegate with the same list of arguments.

typeof(&F.init.foo) dg;


Regards
- Puneet


Re: Calling an alias for a Class method in another scope

2012-06-01 Thread d coder
On Fri, Jun 1, 2012 at 7:40 PM, Mehrdad  wrote:

> Another way to phrase it would be that D is forcing you to to use
> templates where they really aren't meant to be used. :\
>
>
No. I am working on a Domain Specific Language and want to cut on the code
the end user has to write. If I were working on an application I would have
coded differently and I am sure D provides for various other ways.

So D is not forcing me here to use this syntax :-)

Regards
- Puneet


Re: Calling an alias for a Class method in another scope

2012-06-01 Thread d coder
Hello Steve


> There is a way, as I hinted :)
>
> I'll show you how, but be prepared to deal with ugliness!
>

All this smart code would be hidden from the end-users so I really do not
care.


> typeof(&F.init.foo) dg; // alternately: void delegate() dg;
> dg.funcptr = &F.foo;// use the type, not the instance, to get the
> function pointer itself instead of a delegate
> dg.ptr = cast(void *)f; // set f is the context pointer
>
> dg(); // now should call f.foo
>
> Let me understand this. Is F here an alias for foo? If so why I need to
mention stuff like &F.foo? It would defeat my purpose if I have to mention
foo by name. But the code you have put here does give me hope. Just that I
am not able to grasp what F and foo represent here. Probably you mean F is
the type of the class that instantiates the template and foo is the alias
for the method I want to call. Am I right?


> Note that this is *not* a virtual call.  That is currently impossible to
> do without using a lambda.
>

For my purpose that is perfectly fine for now.

Thanks for throwing light on delegates. You have shown me hope :)

- Regards
- Puneet


Re: Calling an alias for a Class method in another scope

2012-06-01 Thread d coder
Hello Steve, thanks for looking at this.

I see the code works when I create the delegate first and then send it to
template.  That is the way you do it here.


> void main() {
>  Foo f = new Foo();
>  auto dg = &f.foo; // need to make a symbol so it can be aliased
>  callfoo!(dg)();
> }
>
>
But it does not work when I put &f.foo directly as the template argument.
But it works when I say:

void main() {
  Foo f = new Foo();
  callfoo!(() {f.foo();})(f);
}

But that still does not solve my problem. In my real code, I want to send
the delegate to a template class. And I am supposed to do that as a member
of another class. So the code looks something like:

Class Bar(alias F) {
 // Call F in some function here
}

Class Foo {
  void foo();
  Bar!(() {foo();}) bar;
}

Again this does not work. Maybe I am expecting too much from D. :-) I am
somewhat aware of the issues involved here. I have seen some earlier D
threads.

But then I thought there might be a way to pass the method function literal
(foo) and separately the this pointer of Foo object and then combine the
two at the other end (inside Bar).

Regards
- Puneet


Re: Calling an alias for a Class method in another scope

2012-06-01 Thread d coder
Hello All

Particularly I would like to know if it is possible at all in D to invoke a
class method transferred to a scope outside the class as an alias argument.

Regards
- Puneet


AST Macros?

2012-06-01 Thread d coder
Greetings

I know there is a plan for D to have AST macros eventually. I wanted to
know if it is a feature being worked upon at this point of time.
Approximately how long it would be before AST Macros see the light of the
day in D?

I know D is an opensource project and I am not trying to put any pressure
here. I am just curious because I think D is a great language for creating
DSL's and having AST Macros will make a big difference.

Regards
- Puneet


Re: Website

2012-06-01 Thread d coder
dlang.org is back.

By the way, is there a PDF version of "D Programming Language
Specification" which is available from Amazon as a kindle edition. It
should be useful to have access to such a manual if the website goes down
again.

Regards
- Puneet


Website

2012-05-31 Thread d coder
Why am I being taken to "Digital Daemon" when I goto http://dlang.org ?

Where can I find official D language site now?

Regards
- Puneet


Calling an alias for a Class method in another scope

2012-05-31 Thread d coder
Greetings

Kindly make me understand this. I have been trying to call an alias for a
class method from another scope. I keep getting an error saying that I need
"this" to call a method. Why will not "this" pointer be available when I am
passing the method symbol along with an object of the class? Is there
another way of doing what I am trying to achieve. I have pasted a sample
code below here.

Regards
- Puneet

void callfoo(alias F, T) (T t) {
  void foo() {
F();   // Error: need 'this' to access member foo
t.F(); // Error: undefined identifier 'F'
  }
}

class Foo {
  void foo() {}
}

void main() {
  Foo f = new Foo();
  callfoo!(f.foo)(f);
}


Re: CTFE slower than expected

2012-05-29 Thread d coder
>
>
> Alright, well I've got a case of beer with your name on it if you can pull
> it off! ;)
>

+1. I too am waiting for CTFE improvements. I am working on a DSL and with
the present limitations, it is impractically slow and memory consuming
while compiling.


Re: Lexer and parser generators using CTFE

2012-05-27 Thread d coder
>
> I would like the parser to effect some side effects. For this purpose, I
> tried including the parser mixin into a class, but I got a strange error
> saying:
>
> Error: need 'this' to access member parse
>
>
Ok. I see my folly. At compile time, there would not be any "this" since
the class has not been instantiated yet.

I will have to think of other solutions. Basically, I am trying to use the
parser to create functions that I can use at run time. But I wanted to
create two functions from the same parser. I have succeeded with creating
one function. I do not want to create two separate parsers because each of
these parsers would add to memory footprint of the compiler.

Any ideas? Maybe I could use tuples here?

Regards
- Puneet


Re: Lexer and parser generators using CTFE

2012-05-27 Thread d coder
>
>
> Generally a parser generated by other tool and accepting tokens returns
> the abstract syntax tree, but it return the evaluated value in the example.
> In other words, it does lexical analysis, parsing and (type) converting at
> a time.
> If you want simply abstract syntax tree, it may be a little pain to use
> ctpg.
>

 Hello Youkei

I am trying to use CTPG for compile time parsing for a DSL I am working on.
I have tried the examples you created in the examples directory.

I would like the parser to effect some side effects. For this purpose, I
tried including the parser mixin into a class, but I got a strange error
saying:

Error: need 'this' to access member parse

I have copied the code I am trying to compile at the end of the email. Let
me know what I could be doing wrong here.

Regards
- Puneet


import ctpg;
import std.array: join;
import std.conv: to;

class Foo
{
  int result;
  mixin(generateParsers(q{
int root = mulExp $;

int mulExp =
  primary !"*" mulExp >> (lhs, rhs){ return lhs * rhs; }
/ primary;

int primary = !"(" mulExp !")" / [0-9]+ >> join >> to!int;
  }));

  void frop() {
result = parse!root("5*8");
  }
}


void main(){
  Foo foo = new Foo();
  foo.frop();
}


Re: Pegged and DMD Compilation Memory

2012-05-23 Thread d coder
> But that might still not be enough


Some 50-100MB additional memory is getting consumed by the compiler each
time I parse a simple expression like "foo > 32;". In the end, if I parse
20 such expressions, the memory usage tops 2GB even while using asModule.

Regards
- Puneet


Re: Pegged and DMD Compilation Memory

2012-05-23 Thread d coder
> Have you guys tried to use asModule?
> https://github.com/PhilippeSigaud/Pegged/wiki/Grammars-as-D-Modules
>

Thanks for the idea. I just gave it a try and the memory came down by about
50%. Additionally the compilation became much faster.

But that might still not be enough :-( I will try to simplify my grammar
rules for now.

Regards
- Puneet


Re: Pegged and DMD Compilation Memory

2012-05-23 Thread d coder
> dmd simply never frees any memory it allocates.


Since GDC uses DMD front-end, I do not think I can get any relief by using
that too. Right?


Pegged and DMD Compilation Memory

2012-05-23 Thread d coder
Greetings

I am trying to use Pegged for compile time parsing. The only issue I am
facing is with the compile time memory. I have a rather simple grammar,
mostly derived from the arithmetic.d example that comes bundled with Pegged.

I am wondering if the memory could be optimized by fine-tuning the code in
the grammar that I have written. I am pasting the code down here for
suggestions. On my 64-bit linux machine my small application is taking as
much as 2.2GB of RAM at the time of compiling the code using DMD 2.059. I
am using the latest Pegged code from github.

Regards
- Puneet

mixin(grammar(
   "CstGrammar:
CstSet <  Cst+
Cst<  Bool ';'
Bool   <  Comparison BoolExpr*
BoolExpr   <  ^('&&'/'||') Comparison
Comparison <  Expr CompExpr?
CompExpr   <  ^('<='/'>='/'!='/'<'/'>'/'==') Expr
Expr   <  Factor AddExpr*
AddExpr<  ^('+'/'-') Factor
Factor <  Primary MulExpr*
MulExpr<  ^('*'/'/') Primary
Primary<  Parens / Number / Variable / ^'-' Primary
Parens <  '(' Bool ')'
Number <~ [0-9]+
Variable   <- Identifier"
));


Re: String mixin syntax sugar

2012-03-20 Thread d coder
> Use template mixins? At least in struct/class area that catches the most
> attention it should work perfectly.


I believe template mixins are equally ugly. Don't you have to explicitly
specify that you are invoking a mixin? Or am I missing something here.

Regards
- Puneet


Re: Compile Time D Expression Parser?

2012-03-11 Thread d coder
> Pegged should have no problem parsing all of D, at least theoretically (I
> don't know of any severe ambiguities in D). So IOW, it can probably do
> what you need it to do.


Oh. I realized that I had missed Pegged announcement by Philippe. I will
have a look at it.

Regards
- Puneet


Re: Compile Time D Expression Parser?

2012-03-11 Thread d coder
Hello  Philippe

> OK, doing a bit of thread necromancy here (3 weeks, still acceptable here?)
>
You are more than welcome. I am still working on the stuff.


> Puneet, I might have something for you. IIUC, you want to parse
> expressions that are
>
> - an association of boolean expressions (&&, ||, !)
> - each boolean expression is an equation (=, <=, >, etc)
> - each equation lhs or rhs is an arithmetic expression (+, -, *, /)
> - atoms in an arithmetic expression can be numbers or variables
>
> Is that it?
>
That would be sufficient for a start. But later I would also like to parse
simple D style if-else conditionals and foreach loops.


> You do realize that any parse tree will for these constructs will be quite
> deep, right? I mean, 10-levels deep or somesuch.
>
10 levels would be good enough.

Regards
- Puneet


Re: Lexer and parser generators using CTFE

2012-02-29 Thread d coder
>
>
> This sounds like something I ran into in my D lexer project. Lexing
> Phobos took upwards of 10-15 seconds, which is extremely slow
> considering that dmd can *compile* it in just a few seconds. So I did
> some profiling, and found out that most of the time was spent formatting
> tokens into strings and running writeln. After I commented that out, the
> running time dropped to just a few seconds. :-)
>
>
And how different was just a few seconds from 10-15 seconds? :-)


Re: Lexer and parser generators using CTFE

2012-02-29 Thread d coder
>
> I'm  afraid being in holidays right now means I do not have easy access to
> GitHub (no git on a pad, and the computer I use to code right now does not
> have any network connection). I'll put all this online in a few days,
> because that must seems like the ramblings of a madman right now...
>

I am eagerly waiting for you to upload the stuff on GitHub.

Regards
- Puneet


Re: Lexer and parser generators using CTFE

2012-02-28 Thread d coder
>
>
> > On Wednesday, February 29, 2012 02:16:12 Christopher Bergqvist wrote:
> > > I agree that the current direction of D in this area is impressive.
> > > However, I fail to see a killer-feature in generating a lexer-parser
> > > generator at compile-time instead of run-time.
> > >
>

CTFE parsing is especially useful for DSEL (Domain Specific Embedded
Languages) or internal DSLs. The advantages are:

1. Syntactic errors (in the parsed constructs)  are given out at compile
time.
2. D reflections are available only at compile time. Referencing the
variables/identifiers in the parsed subset of DSL with the mainstream D
code is impossible without reflections in place.

Regards
- Puneet


Re: Compile Time D Expression Parser?

2012-02-27 Thread d coder
>
>
> Parsing method which the generated parser employs is Recursive Descent
> Parsing.
> And the behavior of the parsers recursive and A is a little bit
> complicated.
> The parser recursive matches the sequence of 'a' whose length is 2^n-1
> such as 1, 3, 7 and 15.
> Anyway, I'm going to write more documentation of ctpg within a few days.
> I hope it'll help you.
>
>
It sure will. Meanwhile, it would help if you can share some example code.

I surely do have an EBNF notation for the expressions I want to parse. Is
it possible to parse any EBNF of arbitrary complexity using your parser
generator?

Regards
- Puneet


Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
>
>
> I know. CTFE is flexible enough and implementing this would be quite
> simple. However, if ctpg serves your needs well, just use that.
>

Thanks Timon

  You mean I do not need to use function style when using CTFE?
  I will try parsing myself as you suggested. This approach would give me a
better handle.

Regards
- Puneet


Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
>
>
> Operator precedence parsers are simple to implement:
>
> http://effbot.org/zone/simple-**top-down-parsing.htm
>

Timon

I want to do all this parsing at compile time in D (using mixins). I have
just started working on this. I am not sure if CTFE allows so much
flexibility. I believe I will have to use functional style as in the link
provided by Kenji. Let me know if I am missing something.

Regards
- Puneet


Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
> Hisayuki Mima's ctpg is compile-time parser generater, and the
> generated parser works in compile time!
> https://github.com/youkei/ctpg
>
> Kenji Hara
>

Thanks Kenji

This is very interesting. Also I think ctpg is being actively developed. I
will try to figure out how to make use of it.

Regards
- Puneet


Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
>
> How different is what you want to do from CTFE?
> http://dlang.org/function.html


I do not want to evaluate the expression in the string at compile time. I
want to parse it at compile time and later at run time, I am required to
process the parse tree and evaluate it in a different fashion (using binary
decision diagrams).

In summary, I need CTFE to parse the expression and create a parse tree
from it. I think this requires a string mixin that takes the expression
string as input and outputs code that builds the corresponding parse tree.

Regards
- Puneet


Compile Time D Expression Parser?

2012-02-25 Thread d coder
Greetings

I need to parse simple D expressions at compile time. I was wondering if
somebody on the list has some example code that could be of help to me.

I am working on an opensource constraint solver  and expressions that I
need to parse can be reasonably complex such as "x + y*n < 32 && x > 4". I
want to code a string mixin that parses such expressions and writes out
code that creates a parse tree for the given expression.

Thanks and Regards
- Puneet


Re: d future or plans for d3

2012-01-03 Thread d coder
>
>
> D's pass-down lambdas do not need memory allocation. As far as I remember
> none of std.algorithm's use of lambda allocates memory.
>
>

On that front Andrei, did you get a chance to discuss my request to make
std.algorithm more usable with Walter?


http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=140807

- Regards


Re: Garbage collection book

2011-10-10 Thread d coder
>
>
> The books have different authors.  I don't suppose someone has both and can
> comment on the differences?  I have the older version as well, but wouldn't
> mind picking up this new one if it brings enough new stuff to the table.


Perhaps you can take a look at the ToC here
http://www.amazon.co.uk/gp/product/toc/1420082795/ref=dp_toc?ie=UTF8&n=266239


Re: function literals cannot be class members

2011-09-23 Thread d coder
On Mon, Jul 18, 2011 at 8:18 PM, Andrei Alexandrescu <
seewebsiteforem...@erdani.org> wrote:
[snip..]


> We need to keep this key strategic advantage. First off, the fact that this
> code isn't accepted:
>
>
> BinaryHeap!(uint[], function (a, b) {return a > b;}) heap;
>
> is a clear bug.
>
>
>  Worst case, BinaryHeap grows a branch which stores/calls a delegate
>> instead of a template parameter.
>>
>
> I'll discuss with Walter, but even without any language change we can
> define a special symbol that means "store this object inside". That symbol
> has nothing interesting about it, e.g.:
>
> /// Use this for comparators with state
> struct Dynamic(T) {}
>
> Heap!(uint[], Dynamic!(bool delegate(uint, uint))) myHeap;
>
> A better solution have us detect from the alias that we need to allocate
> storage for it in the Heap object.
>
>

Andrei

 Did you get a chance to take this up with Walter? I wanted to make sure
that we do not forget this issue altogether. Should I file this on Bugzilla?

Regards
- Puneet


Re: D in the TIOBE top

2011-09-09 Thread d coder
>From the Article 



> Wikipedia gives a hint about the comeback of D: "The release of Andrei
> Alexandrescu's book 'The D Programming Language' on June 12, 2010 marked the
> stabilization of D 2.0." In the charts we can see that the D language is
> gradually rising again since that date.


Should we look forward to more books on D now?

Regards
- Puneet


Re: Overloading comparison and Equality Operators

2011-09-06 Thread d coder
> Actually not expression templates. I am porting a BDD (Binary decision
> diagrams) library from C++ to D. The comparison operators are just
> implemented as relations that return another BDD. A BDD would then
> evaluate to 0 or 1 depending on many other factors and other BDDs. A
> BDD actually represents a node on an acyclic graph.

Excuse my poor knowledge of expression templates. It seems I am doing
something similar to expression templates, but not at meta-programming
level.

Regards
- Puneet


Re: Overloading comparison and Equality Operators

2011-09-06 Thread d coder
>>> For example a < b is re-written as a.opCmp(b) < 0.
>>> In my application, I wanted to overload comparison and equality
>>> operators to return user defined values. Is that possible in D? If so
>>> how?
>>
>> What are you trying to do?
>> In the end opCmp can return any value or object that works in the
>> rewritten case 'a.opCmp(b) < 0'.
>
> Which is a fancy way of returning an int. Probably he wants to implement
> expression templates.
>

Actually not expression templates. I am porting a BDD (Binary decision
diagrams) library from C++ to D. The comparison operators are just
implemented as relations that return another BDD. A BDD would then
evaluate to 0 or 1 depending on many other factors and other BDDs. A
BDD actually represents a node on an acyclic graph.

Being able to overload comparison operators more generically would
have helped. For now I am using named functions as Timon suggested.

Regards
- Puneet


Overloading comparison and Equality Operators

2011-09-06 Thread d coder
Greetings

It seems D assumes that these operators should return a bool value.
For example a < b is re-written as a.​opCmp(b) < 0.
In my application, I wanted to overload comparison and equality
operators to return user defined values. Is that possible in D? If so
how?

Regards
- Puneet


Re: Mixin template evaluated to string can convert to string mixin expression implicitly

2011-08-21 Thread d coder
On Mon, Jun 27, 2011 at 2:09 PM, Don  wrote:

> kenji hara wrote:
>
>> Issue in bugzilla:
>>  
>> http://d.puremagic.com/issues/**show_bug.cgi?id=6207
>> Test implementation:
>>  https://github.com/9rnsr/dmd/**commit/**52e4491cf6bf9ccf6dccc1fa60581f**
>> d6797d39b3
>>
>> String mixin feature in D is very useful, but its syntax is bit ugly.
>> My proposal will make it more softly, and introduces more generative
>> programming.
>>
>> Any thoughts?
>>
>> Kenji
>>
>
> Yes, it's _less_ ugly, but I just don't think it gets rid of enough of the
> ugliness. You still get that horrid q{ } around the code. I also don't see
> any reason for the feature to be restricted to templates.
> The effect is a bit like sugar on syntax anchovies .
>

Any chance of this feature getting into D language?

I believe that this would be very useful for domain specific embedded
languages.

Regards
- Puneet


  1   2   >