Sorry to be late coming to this.
It would great to be able to push D as a CPython extension
language.
However the state of pyd.dsource.org and places reached from it
do make
it seem that the project died in 2009.
ariovistus' GitHub project on Bitbucket is moving but
everything else
appears
On Sunday, 19 January 2014 at 20:46:06 UTC, monarch_dodra wrote:
I'll file it as an ER, and try to get Kenji on it.
https://d.puremagic.com/issues/show_bug.cgi?id=11952
As a workaround, it is usually recommended in the destructor to
try to detect "initial state", and do nothing in such cases.
On Sunday, 19 January 2014 at 19:24:23 UTC, Benjamin Thaut wrote:
Yes this looks like a bug to me. Please file a bug report at
https://d.puremagic.com/issues/
Kind Regards
Benjamin Thaut
Here is a reduced case:
//
import std.stdio;
struct B
{
A sup;
this(A a)
{
That's std.array.join() there. However, I notice that the
output (the order of elements) differs from the one on that
page you linked earlier.
The order shouldn't be a problem. Join is a great idea. I'd
thought it was only for an array of strings. Thanks for all the
help!
When a struct is passed to a function as argument, it is first
copied and at the end destructed. But in the following code it is
not copied, yet still destructed?
module main;
import std.stdio;
struct C
{
A[] _objs;
this(A[] objs...)
{
writeln(` C thi
On Sunday, 19 January 2014 at 15:28:04 UTC, Tobias Pankrath wrote:
On Sunday, 19 January 2014 at 15:12:07 UTC, Tobias Pankrath
wrote:
On Sunday, 19 January 2014 at 15:03:13 UTC, monarch_dodra
wrote:
So, my conclusion, "*" might be a workable solution. But
simply taking by ref would be cleaner
On Wed, 2013-12-11 at 12:56 +0100, John Colvin wrote:
> On Wednesday, 11 December 2013 at 11:41:11 UTC, Chris wrote:
[…]
> > Have you had a look at this:
> >
> > http://pyd.dsource.org/
> > https://github.com/dansanduleac/pyd
>
> both of those are out of date, this is where development is now:
>
How can i get the value from an enum when passed to a function?
For example i have the following code:
import std.stdio;
enum E : string
{
one = "1",
two = "2",
}
void print(E e)
{
writefln("%s", e);
}
void main(string[] args)
{
print(E.one);
}
The output is '
On Sunday, 19 January 2014 at 18:07:46 UTC, Tobias Pankrath wrote:
You'll need to cast the value, but you can guard this cast
using std.traits.OriginalType or write a toOType function.
auto toOType(E)(E e) if(is(E == enum)) { return
cast(OriginalType!E) e; }
I never get these is-expressions
Am 19.01.2014 18:48, schrieb Lemonfiend:
import std.stdio;
struct C
{
A[] _objs;
this(A[] objs...)
{
writeln(` C this()`);
_objs = objs;
// A.this(this) is not called
// yet A.~this IS called
}
}
struct B
{
A sup;
alias sup th
I just tried the new beta, and the issue remains.
On Sunday, 19 January 2014 at 17:37:54 UTC, Gary Willoughby wrote:
How can i get the value from an enum when passed to a function?
For example i have the following code:
import std.stdio;
enum E : string
{
one = "1",
two = "2",
}
void print(E e)
{
writefln("%s", e);
}
On Sunday, 19 January 2014 at 15:12:07 UTC, Tobias Pankrath wrote:
On Sunday, 19 January 2014 at 15:03:13 UTC, monarch_dodra wrote:
So, my conclusion, "*" might be a workable solution. But
simply taking by ref would be cleaner, and make more sense as
a whole.
Or a special template constraint
On Saturday, 18 January 2014 at 23:06:42 UTC, Tobias Pankrath
wrote:
I actually didn't think that a ptr (to output range) would
work. This way we can have best of both worlds and I'm happy
with it.
A fun fact is that since "." notation works with pointers, more
often than not, if "T" verifies
On Sunday, 19 January 2014 at 15:03:13 UTC, monarch_dodra wrote:
So, my conclusion, "*" might be a workable solution. But simply
taking by ref would be cleaner, and make more sense as a whole.
Or a special template constraint path for T*.
foo(T)(T t) if (is(T = Q*)) && manyOtherChecks!(Q)
foo
CJS:
units[s] = unitlist.filter!(x => any!(y => s==y));
One of your problems is that any that needs some range to work on.
Bye,
bearophile
On Sunday, 19 January 2014 at 06:57:37 UTC, CJS wrote:
Ah, I'd been wondering if there was something like this. But
why does it need unitlist's address? (Assume & has the same
meaning as in C and C++.)
Look at the docs for Appender. It can either provide its own
storage, or use an existing o
On Sunday, 19 January 2014 at 02:10:01 UTC, CJS wrote:
That's more concise but I also think it's more confusing. I
assume that to!string is doing the exact same thing, but I was
hoping for something to do the appropriate implicit
conversations. Especially to a range of length 1, though I can
Thanks!
auto app = appender(&unitlist);
Ah, I'd been wondering if there was something like this. But why
does it need unitlist's address? (Assume & has the same meaning
as in C and C++.)
This one seems like it should be unitlist.filter!(x => x.any!(y
=> s==y)).array();
Oh. D
to!string(c) ===> c.text
That's more concise but I also think it's more confusing. I
assume that to!string is doing the exact same thing, but I was
hoping for something to do the appropriate implicit
conversations. Especially to a range of length 1, though I can
understand that kind of
On Saturday, 18 January 2014 at 21:55:54 UTC, Tobias Pankrath
wrote:
I want to print a tree structure and need to keep track of the
indention for different parts of the tree. My idea was to write
a generic wrapper for an output range that outputs tabs when it
encounters a newline. This wrapper
On Saturday, 18 January 2014 at 22:58:59 UTC, bearophile wrote:
monarch_dodra:
*I* think it should. File a report, and I'll see what I can do
about it. The problem with these kinds of things though might
be breaking existing code...
Given the frequency of bugs caused by such functions that
On Saturday, 18 January 2014 at 21:55:54 UTC, Tobias Pankrath
wrote:
I want to print a tree structure and need to keep track of the
indention for different parts of the tree. My idea was to write
a generic wrapper for an output range that outputs tabs when it
encounters a newline. This wrapper
monarch_dodra:
*I* think it should. File a report, and I'll see what I can do
about it. The problem with these kinds of things though might
be breaking existing code...
Given the frequency of bugs caused by such functions that require
a pointer to the data, I think that a breaking change is
CJS:
Unfortunately my current best attemp doesn't compile:
What errors are you seeing?
auto cross(R1, R2)(in R1 A, in R2 B){
Better to add a space before the open brace.
Also you may want to remove "in" if you want to use cross() on
lazy ranges.
return cartesianProduct(A,B).map!(
I want to print a tree structure and need to keep track of the
indention for different parts of the tree. My idea was to write a
generic wrapper for an output range that outputs tabs when it
encounters a newline. This wrapper has internal state and if I
want to use formattedWrite with this wrap
units[s] = unitlist.filter!(x => any!(y => (s == y)));
And you don't need a pair of ( ):
units[s] = unitlist.filter!(x => any!(y => s == y));
And now you need to feed any with some range.
Bye,
bearophile
import std.stdio, std.conv, std.algorithm, std.array;
string[] cross(in string A, in string B) {
return cartesianProduct(A, B).map!(ab => ab[].text).array;
}
void main() {
cross("ab", "12").writeln;
}
But note that currently cartesianProduct doesn't return the
pairs in a natural orde
Hi!
I made similar questions here a month ago, but also couldn't get definitive
answers. I just sent a message about this to the main D forum. Let's see if
we have better luck there :-)
Cheers,
LMB
On Fri, Jan 17, 2014 at 5:39 PM, Lemonfiend wrote:
> I think this is what you are looking for
remove uses DeleteFile, but MSDN says
To remove an empty directory, use the RemoveDirectory function.
so remove probably won't work on directories.
Le 13/01/2014 22:47, Benjamin Thaut a écrit :
Am 13.01.2014 21:52, schrieb Xavier Bigand:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,9)
glBindBuffer(GL_ARRAY_BUFFER,10)
glEnableVertexAttribArray(0)
glVertexAttribPointer(0,3,GL_FLOAT,false,12,)
glBindBuffer(GL_ARRAY_BUFFER,11)
glEnableVertexAtt
CJS:
I'm trying to write a D function that does the same as this
Python function:
def cross(A, B):
"Cross product of elements in A and elements in B."
return [a+b for a in A for b in B]
where A and B are strings. (So cross("ab","12") is ["a1", "b1",
"a2", "b2"]).
One solution:
im
Nodes are reference types in D, so probably you don't need to
use a * for Node. Alternatively use a struct handled by pointer.
"auto content;" can't compile, you need a type, or you have to
template Node on T and use it for content.
Bye,
bearophile
Youre right, it compiles now, and the obje
On Friday, 17 January 2014 at 12:52:09 UTC, Hugo Florentino wrote:
On Fri, 17 Jan 2014 07:07:35 +, Kagamin wrote:
Does it fail for that one directory only or for any directory?
Interesting question. I would have to do more tests with odd
names, but apparently both remove() and rename() ha
Arjan Fetahu:
Since each Node connects to multiple others i came up with this
solution.
class Node {
auto content;
Node*[] nodes;
//..constructor..
}
Nodes are reference types in D, so probably you don't need to use
a * for Node. Alternatively use a struct handled by pointer.
Keep in mind that, unlike in c++, D classes are reference
types:
class Node
{
Node[] nodes; // This is valid
}
Structs are value types though, so using a struct in the above
example is illegal.
You mean:
struct Node {
Node[] nodes;
}
or
struct Node {
Node*[] nod
Hit the wrong key and posted too early. I finished the code
sample below. My main question was for something prettier and
more concise. I feel like the code below is long and not as
pretty in comparison to the Python. Sometimes that's an
unavoidable consequence of static typing, but I'm not sur
I'm trying to write a D function that does the same as this
Python function:
def cross(A, B):
"Cross product of elements in A and elements in B."
return [a+b for a in A for b in B]
where A and B are strings. (So cross("ab","12") is ["a1", "b1",
"a2", "b2"]).
It's easy to get somethin
On Saturday, 18 January 2014 at 07:56:15 UTC, Stanislav Blinov
wrote:
Although that won't give you a string[], but in a dchar[][].
...but that is solvable:
auto strings = array(cross("ab","12").map!"to!string(a)"());
Or maybe even by providing additional overload:
auto cross(alias fun,R1,R
I'd say
import std.algorithm;
auto cross(R1,R2)(R1 a, R2 b) {
return cartesianProduct(a,b).map!"[a[0]]~[a[1]]"();
}
You can always:
import std.array;
auto strings = array(cross("ab","12"));
Although that won't give you a string[], but in a dchar[][].
I regularly rebuild and use DMD git master locally on Ubuntu
13.10. Yesterday my toolchain dmd fails to link all D programs
with the error:
Example compilation output from dmd
/home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libphobos2.a(sections_linux_4c8_e6.o):src/rt/sections_linux.d:fu
Through Reddit I've found posts about hash-based associative
arrays:
http://bannalia.blogspot.it/2013/10/implementation-of-c-unordered.html
http://bannalia.blogspot.it/2014/01/a-better-hash-table.html
Those little images like this one are excellent at explaining in
a short space the basic stru
On Wednesday, 8 January 2014 at 20:21:22 UTC, John Carter wrote:
> Very well written, a pleasure to read.
And very hard to translate! :)
Leaping off the immediate topic of computer language D into the
realm
of human languages English and Turkish...
With the Sapir–Whorf hypothesis in the b
It seems to be somewhat similar to std.parallelism
(http://dlang.org/phobos/std_parallelism.html)
I have seen that before, didn't know if there was anything closer
with the task scheduler and worker threads described in the
documentation for TBB, or if that was the closest thing.
I see that
On Tuesday, 31 December 2013 at 10:35:46 UTC, thedeemon wrote:
I've missed all the DUB discussions here and couldn't find the
answer to my question in the docs, so here it is, very simple:
I've got an app with one dependency stated in package.json as
"dependencies": {
"pe
On Sunday, 29 December 2013 at 10:16:33 UTC, ponce wrote:
If you want deterministic destruction, you have plenty of
choices:
- scoped!
- using structs instead
- scope(exit)
- RefCounted!
- Unique!
- ...
Do you happen to know of any clever technique to make object, and
everything that inherits
Mike:
How does the garbage collector know when something has gone out
of scope
The garbage collector doesn't know that.
Look in Wikipedia how a Mark&Sweep GC works.
Bye,
bearophile
On 12/29/2013 04:00 AM, Mike wrote:
On Sunday, 29 December 2013 at 10:16:33 UTC, ponce wrote:
If you want deterministic destruction, you have plenty of choices:
- scoped!
- using structs instead
- scope(exit)
- RefCounted!
- Unique!
- ...
Do you happen to know of any clever technique to make o
Ok, I understand that, but since I don't have a garbage
collector, what must I implement to call the destructor when it
goes out of scope?
Another way of asking the question is: How does the garbage
collector know when something has gone out of scope and is
therefore safe to collect? And whe
2. Why does nextPermutation hang up for empty arrays? I
suppose that's a bug?
I suppose so. Please file it. If it is deemed "illegal", at the
very least, it should throw.
My fault, i mis-used it. The right behavior for ranges of size 0
and 1 is checked explicitly in the unittests.
Ivan K
On Saturday, 28 December 2013 at 23:38:38 UTC, Ivan Kazmenko
wrote:
Ouch, is it an exception hard-coded into the language itself?
I thought it's just the nextPermutation's parameter type
restrictions which don't allow "char []"...
No, a "char[]" is just a "char[]" as far as the language is
c
Also destructors are not guaranteed to be run by D specification.
It is perfectly legal to skip such cleanup step upon program
termination.
http://dlang.org/class.html#destructors :
"The garbage collector is not guaranteed to run the destructor
for all unreferenced objects. Furthermore, the o
On Saturday, 28 December 2013 at 23:07:21 UTC, monarch_dodra
wrote:
Also, the example at
http://dlang.org/phobos/std_algorithm.html#nextPermutation
is wrong:
while (nextPermutation(a)) { }
should in fact be
do { } while (nextPermutation(a));
as above, or we miss the very first permutation.
Note
I've missed all the DUB discussions here and couldn't find the
answer to my question in the docs, so here it is, very simple:
I've got an app with one dependency stated in package.json as
"dependencies": {
"pegged": "~master"
}
When I build my app with
dub build --
On 2013-12-28 22:47, Jeremy DeHaan wrote:
Since the C functions can't access anything from D code save for what is
passed through as parameters, can it be called pure? And if so, does the
compiler know how to distinguish C and D in this instance and make it
inherently pure? Does purity do anythi
On Sunday, 29 December 2013 at 06:53:08 UTC, Mike Parker wrote:
On 12/29/2013 2:03 PM, Mike wrote:
x's destructor never gets called. What do I need to implement
to have
the destructor called when x goes out of scope?
Class destructors are not called when an object goes out of
scope. The
On Sunday, 29 December 2013 at 06:58:03 UTC, Mike wrote:
Ok, I understand that, but since I don't have a garbage
collector, what must I implement to call the destructor when it
goes out of scope?
Patch compiler to make all classes scope classes. But that won't
be D anymore.
Ali Çehreli:
On 12/29/2013 04:00 AM, Mike:
Do you happen to know of any clever technique to make object,
and
everything that inherits from it, a referenced counted object?
There is std.typecons.RefCounted:
http://dlang.org/phobos/std_typecons.html#.RefCounted
I think it only works on a
So, these are the commands I put in:
../gdc/x86_64/gdc -c -fPIC -B ../gdc/x86_64 -I
../gdc/x86_64/phobos test.d
This one worked fine, as expected.
The problem is here:
../gdc/x86_64/gdc -lgphobos2 -shared -B ../gdc/x86_64 test.o -o
test.so
And this is what the problem outputs:
ld: /lib/../li
On 12/29/2013 2:03 PM, Mike wrote:
x's destructor never gets called. What do I need to implement to have
the destructor called when x goes out of scope?
Class destructors are not called when an object goes out of scope. They
are called by the garbage collector only when memory needs to be
On Saturday, 28 December 2013 at 23:05:54 UTC, monarch_dodra
wrote:
1. This is a minimal example of trying the permutations of a
character array.
-
import std.algorithm;
void main () {
char [] a;
do { } while (nextPermutation(a));
}
-
This gives a compile error. However, it work
I'm trying to implement a very minimal D runtime for the ARM
Cortex-M platform. I've been quite successful so far, but I'm
now getting into reference types and I need to understand better
what D does under the hood.
I have a working malloc/free implementation, but don't have a
garbage collec
On Saturday, 28 December 2013 at 22:55:39 UTC, Ivan Kazmenko
wrote:
Another quick question, two of them.
1. This is a minimal example of trying the permutations of a
character array.
-
import std.algorithm;
void main () {
char [] a;
do { } while (nextPermutation(a));
}
-
This
On Saturday, 28 December 2013 at 22:58:43 UTC, Ivan Kazmenko
wrote:
Also, the example at
http://dlang.org/phobos/std_algorithm.html#nextPermutation
is wrong:
while (nextPermutation(a)) { }
should in fact be
do { } while (nextPermutation(a));
as above, or we miss the very first permutation.
Note
64 matches
Mail list logo