On Sunday, 6 September 2015 at 14:36:53 UTC, chris stevens wrote:
Hi All,
I am considering using D for my latest project and there are a
few features I would like and am not entirely sure at this
point whether D has them. They are:
- dynamic creation of classes/structs at runtime (think I
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar
wrote:
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis
wrote:
If you're returning a range, you should be returning auto.
@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`. However there are times when
you
On 09/08/2015 06:37 AM, Steven Schveighoffer wrote:
I think this warrants a bug report, iota with only floats as parameters
should result in floats.
https://issues.dlang.org/show_bug.cgi?id=15033
Ali
On Tue, 2015-09-08 at 07:33 +, Dominikus Dittes Scherkl via
Digitalmars-d-learn wrote:
> On Tuesday, 8 September 2015 at 05:50:30 UTC, Russel Winder wrote:
> > void main() {
> > immutable imax = 10;
> > immutable jmax = 10;
> > float[imax][jmax] x;
> > foreach(int
On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Hi. I'm playing around with D for a while and I would like to
switch. But here is one thing, I need an answer for. In the
Docs is mentioned that it is not sure that the DTor of a class
is called. But what if I have struct, which holds a
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar
wrote:
The only way to make it work is `.array.idup` the output of
`filter`. For example:
auto result = reduce!(
(acc, num) => acc.filter!(
fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)
On Tuesday, 8 September 2015 at 20:01:15 UTC, chris stevens wrote:
Thanks for the reply Kagamin, just had a quick look at dparse
and not sure how I could use it in the way you describe. Any
examples of this?
As I understand, you wanted to build an AST tree and format it to
string?
On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Besides, we live in 2015 and that is not C where I have to
clean my code manually, so this option would be ridiculous :D
The difference is that in C you need to manage POD memory too.
Manual management of non-POD resources is a problem
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar
wrote:
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis
wrote:
[...]
@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`. However there are times when
you need to pass the `auto` value to another function and
On Wednesday, 9 September 2015 at 07:59:57 UTC, Sebastiaan Koppe
wrote:
What is going wrong is that the types aren't the same. That is,
the type of the seed you supplied - `typeof(foobars)` - isn't
the type that your function returns - `typeof(acc.filter!...)`.
Alright. So, `reduce` initial
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis
wrote:
If you're returning a range, you should be returning auto.
@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`. However there are times when you
need to pass the `auto` value to another function and the
receiving
Hi. I'm playing around with D for a while and I would like to
switch. But here is one thing, I need an answer for. In the Docs
is mentioned that it is not sure that the DTor of a class is
called. But what if I have struct, which holds a C Handle which
is destroyed as soon as the struct gets
Given a C++ class that looks like this:
class Foo {
static void Initialize(const SomeObject&);
virtual void func1();
}
The documentation at [1] doesn't say anything about how to handle
static member functions like Initialize, nor do I see anything
about references. I assume I can
On Wednesday, 9 September 2015 at 08:24:06 UTC, Kagamin wrote:
As I understand, you wanted to build an AST tree and format it
to string?
Thanks again. So I can build an AST and convert it to full D
source from that? I think that's what i'm likely going need to do.
On Wednesday, 9 September 2015 at 09:55:21 UTC, Mike Parker wrote:
The documentation at [1] doesn't say anything about how to
[1] http://dlang.org/cpp_interface.html
On Tuesday, 8 September 2015 at 21:51:03 UTC, wobbles wrote:
"Previously undefined". As far as I know, this is impossible in
D. Thr compiler has to know how much memory to allocate/request
and it has to know that at compiletime (else it wouldn't be the
compiler!)
On Wednesday, 9 September 2015 at 08:29:20 UTC, cym13 wrote:
You are using reduce in a weird way here...
Oh? Perhaps it was all because of the lame example I used :-)
The real problem I was trying to solve, source of which I just
pushed[1], was the `select` method on line 130. Is this
On Wednesday, 9 September 2015 at 09:14:30 UTC, Atila Neves wrote:
So, if your use-case depends on information from the
file-system, user interaction, networking, etc. then your only
choice is to generate text files with D code and compile it.
If, on the other hand, it's all defined by the
On Tuesday, 8 September 2015 at 21:51:03 UTC, wobbles wrote:
"Previously undefined". As far as I know, this is impossible in
D. Thr compiler has to know how much memory to allocate/request
and it has to know that at compiletime (else it wouldn't be the
compiler!)
There was also this:
On 2015-09-09 11:55, Mike Parker wrote:
Given a C++ class that looks like this:
class Foo {
static void Initialize(const SomeObject&);
virtual void func1();
}
The documentation at [1] doesn't say anything about how to handle static
member functions like Initialize, nor do I see
On 09/08/2015 12:30 PM, chris stevens wrote:
> create new
> (previously undefined) classes in D at runtime that I could then use
> with Object.factory to create instances of.
SDC is a D compiler as a library but as far as I know, it's not complete
yet:
https://github.com/SDC-Developers/SDC
On Wednesday, 9 September 2015 at 06:37:17 UTC, Ali Çehreli wrote:
https://issues.dlang.org/show_bug.cgi?id=15033
Ali
https://github.com/D-Programming-Language/phobos/pull/3641
On Wednesday, 9 September 2015 at 09:08:28 UTC, Atila Neves wrote:
No, it doesn't. It needs to know what the compile-time
interface is, i.e. what it can do with that type. If the type
in question happens to be an InputRange, then the consumer
function would be:
void func(R)(R range)
Static functions are declared with `static` storage class. This
looks so basic, it's even not documented in language spec, lol.
In D classes are reference types by default.
On Wednesday, 9 September 2015 at 11:30:26 UTC, Bahman Movaqar
wrote:
For the lame example I gave, something similar occurred to me
at first; but then I thought 4 `filter`s (assuming `all` is
simply a `filter`) might be non-idiomatic as it might incur
some performance penalty.
As those are
On Wednesday, 9 September 2015 at 11:49:33 UTC, Kagamin wrote:
Static functions are declared with `static` storage class. This
looks so basic, it's even not documented in language spec, lol.
Yes, I get that. But how does that work when you're linking to a
C++ library and the translation of
But if others use my code they must think about finalizing the
classes? That is very awkward.
I'll take a look at Rust and otherwise I will stick with C++.
Thanks for you answer. :)
On Wednesday, 9 September 2015 at 14:36:24 UTC, Q wrote:
But if others use my code they must think about finalizing the
classes? That is very awkward.
classes, yes but structs, no.
I'll take a look at Rust and otherwise I will stick with C++.
Thanks for you answer. :)
Well, resource
On Wednesday, 9 September 2015 at 15:32:58 UTC, Adam D. Ruppe
wrote:
On Wednesday, 9 September 2015 at 15:24:57 UTC, Q wrote:
I thought that is not guaranteed, according to the docs?
It is possible that the GC will never actually run, but you can
force it to if you need it to by calling
On Wednesday, 9 September 2015 at 10:23:55 UTC, chris stevens
wrote:
http://wiki.dlang.org/Dynamic_typing
This is what I saw that made me think that I could. Have had
another closer look and I do believe it's possible.
These are things I wrote, so let me explain how they work: they
do not
On Wednesday, 9 September 2015 at 14:57:26 UTC, Adam D. Ruppe
wrote:
On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Can I be sure that the Handle is destroyed as soon as the
class is destroyed?
It will do that automatically.
Like the others said, you won't be sure when the class is
And sorry if that sounds rude, I'm just in a hurry. I just think
D is not mature enough for serious stuff. :) That is of course
only my personal opinion.
On Wednesday, 9 September 2015 at 15:24:57 UTC, Q wrote:
I thought that is not guaranteed, according to the docs?
It is possible that the GC will never actually run, but you can
force it to if you need it to by calling GC.collect at any time.
On Wednesday, 9 September 2015 at 15:37:50 UTC, Q wrote:
Yes, but according to the specs it is not guaranteed that the
GC calls the DTor if the Object is collected.
Where? This page says pretty plainly:
http://dlang.org/class.html#destructors
"The garbage collector calls the destructor
On Wednesday, 9 September 2015 at 15:37:50 UTC, Q wrote:
Yes, but according to the specs it is not guaranteed that the
GC calls the DTor if the Object is collected.
Note that I believe this is the same as in Java (though not C#,
interestingly enough). In Java an object's destructor is not
On Wednesday, 9 September 2015 at 13:17:53 UTC, Mike Parker wrote:
Yes, I get that. But how does that work when you're linking to
a C++ library and the translation of the C++ class to D is an
interface? Or is it possible now to link D classes directly
with C classes?
Classes and templates
On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Can I be sure that the Handle is destroyed as soon as the class
is destroyed?
It will do that automatically.
Like the others said, you won't be sure when the class is
destroyed unless you have the user code take ownership of it.
(This
On Wednesday, 9 September 2015 at 15:10:33 UTC, Q wrote:
But since D has a GC and (per default) force to heap allocate a
class. So IMO the GC should also destroy it, everything else is
just awkward.
Well, it *does* by default. If that's what you want, just do it
the plain way with simple
On Wednesday, 9 September 2015 at 15:19:04 UTC, Adam D. Ruppe
wrote:
On Wednesday, 9 September 2015 at 15:10:33 UTC, Q wrote:
But since D has a GC and (per default) force to heap allocate
a class. So IMO the GC should also destroy it, everything else
is just awkward.
Well, it *does* by
On Wednesday, 9 September 2015 at 20:17:44 UTC, cym13 wrote:
This is subtly missing the main question: isn't C++-like memory
management of D classes possible with Unique, RefCounted and
Scoped?
- Unique
C++ has move semantics which make moves explicit. D's Unique is
more like the
On Wednesday, 9 September 2015 at 20:19:44 UTC, Daniel N wrote:
For the record, I think D made the right decision... omitting
friends.
However there's one case in particular which I find useful,
anyone see a good workaround for this?
#include
class Friendly
{
private:
int val;
Couldn't you use setIntersection together with reduce?
Doesn't seem like the most efficient solution, but its less
typing and most likely will have no bugs.
For the record, I think D made the right decision... omitting
friends.
However there's one case in particular which I find useful,
anyone see a good workaround for this?
#include
class Friendly
{
private:
int val;
Friendly(int&& val) : val(val) {}
friend std::unique_ptr
I have a DateTime[][] arg (actually my own date type, but that
shouldnt matter). Ordered by time series ticker (eg a stock) and
then the date.
eg arg[0] might be the dates relating to IBM and arg[0][0] would
be the date of the first point in IBM time series.
I would like to find the
On Wednesday, 9 September 2015 at 20:17:44 UTC, cym13 wrote:
This is subtly missing the main question: isn't C++-like memory
management of D classes possible with Unique, RefCounted and
Scoped? I understand the limitations you mentioned, but it
I don't think it is a good idea to tell C++
On Wednesday, 9 September 2015 at 20:18:57 UTC, Paul wrote:
Is it possible to call a function like this...
void foo(ref int[] anArray)
...with slices of static arrays? I thought I might be able to
use [0..$-1] but to no avail - I get an error like this (which
is confusing!):
Note that the
On Wednesday 09 September 2015 22:18, Paul wrote:
>
> Is it possible to call a function like this...
>
> void foo(ref int[] anArray)
>
> ...with slices of static arrays? I thought I might be able to use
> [0..$-1] but to no avail - I get an error like this (which is
> confusing!):
>
> (ref
On Wednesday, 9 September 2015 at 20:34:03 UTC, Ola Fosheim
Grøstad wrote:
On Wednesday, 9 September 2015 at 20:17:44 UTC, cym13 wrote:
This is subtly missing the main question: isn't C++-like
memory management of D classes possible with Unique,
RefCounted and Scoped? I understand the
On Wednesday, 9 September 2015 at 16:59:09 UTC, Adam D. Ruppe
wrote:
That's typically right, but since this case does it in-place
instead of pointed, the zero length array is most accurate.
I didn't consider that the name is placed right after the struct.
Thanks !
On Wednesday, 9 September 2015 at 11:30:26 UTC, Bahman Movaqar
wrote:
On Wednesday, 9 September 2015 at 08:29:20 UTC, cym13 wrote:
The way I would have written it is:
auto result = foobars.filter!(fb => nums.all!(n => (fb.x *
fb.y) > n))
.filter!(fb => nums.all!(n => fb.x
The struct core.sys.linux.sys.inotify.inotify_event contains the
field "char[0] name" which corresponds to "char name[]" in C.
Why it has been translated to "char[0]" ?
For me "char*" would have been more appropriate.
On Wednesday, 9 September 2015 at 16:49:39 UTC, badlink wrote:
The struct core.sys.linux.sys.inotify.inotify_event contains
the field "char[0] name" which corresponds to "char name[]" in
C.
Why it has been translated to "char[0]" ?
In that structure, the name is appended directly to the end
On Wednesday, 9 September 2015 at 01:35:26 UTC, Joel wrote:
auto line = terminal.getline("your prompt: ");
Huh, that should work unless your terminal is outrageously narrow
or maybe output starting on the right side of the screen already.
But I can't look much further without having a
Maybe you can try gnu readline instead:
extern(C) char* readline(const(char)* prompt);
pragma(lib, "readline");
pragma(lib, "curses");
void main() {
auto line = readline("your line: ");
import std.stdio, std.conv;
writeln(to!string(line));
}
On Wednesday, 9 September 2015 at 19:53:55 UTC, ponce wrote:
Oops, posted by mistake.
On Wednesday, 9 September 2015 at 19:48:00 UTC, cym13 wrote:
Hi,
I know C++ and D without being a C++ or D guru (I know way
more about D though). When talking about memory management the
problem of RAII is
On Wednesday, 9 September 2015 at 20:05:06 UTC, ponce wrote:
C++ only has a D struct equivalent so all destructors are
called deterministically. It's the addition of classes that
create the problems in D.
C++ can also throw by value, something that D can't really do.
C++ objects can be:
-
Is it possible to call a function like this...
void foo(ref int[] anArray)
...with slices of static arrays? I thought I might be able to use
[0..$-1] but to no avail - I get an error like this (which is
confusing!):
(ref int[] anArray) is not callable using argument types (int[])
I've
Hi,
I know C++ and D without being a C++ or D guru (I know way more
about D though). When talking about memory management the problem
of RAII is often mentioned along with the fact that classes use
the GC. I know well the difference between structs and classes
and don't want to talk about
On Wednesday, 9 September 2015 at 16:49:39 UTC, badlink wrote:
The struct core.sys.linux.sys.inotify.inotify_event contains
the field "char[0] name" which corresponds to "char name[]" in
C.
Why it has been translated to "char[0]" ?
For me "char*" would have been more appropriate.
It's a
On Wednesday, 9 September 2015 at 19:48:00 UTC, cym13 wrote:
Hi,
I know C++ and D without being a C++ or D guru (I know way more
about D though). When talking about memory management the
problem of RAII is often mentioned along with the fact that
classes use the GC. I know well the
On Wednesday, 9 September 2015 at 20:37:40 UTC, cym13 wrote:
Hence my question: in what? (I assume you are talking about
Unique RefCounted etc and not about classes).
I think you should just refer them to the relevant man pages.
Explanations are just going to be confusing as they are
On Wednesday, 9 September 2015 at 17:47:44 UTC, Adam D. Ruppe
wrote:
Maybe you can try gnu readline instead:
extern(C) char* readline(const(char)* prompt);
pragma(lib, "readline");
pragma(lib, "curses");
void main() {
auto line = readline("your line: ");
import std.stdio,
On Wednesday, 9 September 2015 at 21:27:05 UTC, Joel wrote:
Thanks Adam. That works better than normal. Up and down don't
work though.
There's another function called add_history for that. Readline is
a pretty popular library (also GPL though, keep that in mind if
you distribute your
63 matches
Mail list logo