On 05/14/2015 06:38 PM, Adam D. Ruppe via Digitalmars-d-learn wrote:
On Friday, 15 May 2015 at 01:03:32 UTC, Charles Hixson wrote:
Yes, that looks as if it would do the job, but what are its
advantages over a simple struct?
None really, except perhaps automatic forwarding of operators which
On Friday, 15 May 2015 at 03:22:43 UTC, rcorre wrote:
On Thursday, 14 May 2015 at 14:57:26 UTC, Idan Arye wrote:
How about a more flexible solution?
http://dpaste.dzfl.pl/2f99cc270651
Neat, thanks!
The range I don't pick may be an expression that would fail, so I
tweaked it to:
SelectRa
I have built a toy dynamic shared library on Mac OS X (in C), and
I have verified that it works from C. Now I would like to call it
from D. So I have created the following interface file:
$ cat hello.di
extern (C):
void printHelloWorld();
which I try to compile and run. But I get the follo
On Thursday, 14 May 2015 at 14:57:26 UTC, Idan Arye wrote:
How about a more flexible solution?
http://dpaste.dzfl.pl/2f99cc270651
Neat, thanks!
On Thursday, 14 May 2015 at 18:44:58 UTC, Steven Schveighoffer
wrote:
It depends on the guts of MyContainer.Range.
I'm assuming MyContainer.Ran
On Friday, 15 May 2015 at 01:03:32 UTC, Charles Hixson wrote:
Yes, that looks as if it would do the job, but what are its
advantages over a simple struct?
None really, except perhaps automatic forwarding of operators
which is easy enough to do on a struct too (and with a struct,
you can do on
On 05/14/2015 01:42 PM, Laeeth Isharc via Digitalmars-d-learn wrote:
On Thursday, 14 May 2015 at 18:42:56 UTC, Charles Hixson wrote:
What are the downsides to simulating a new type with a struct.
What I have in mind is something along the lines of:
struct myType
{ uint64_t value;
}
The go
On Thursday, 14 May 2015 at 22:55:43 UTC, Ali Çehreli wrote:
Yes, it is weird but that value happens to be the address of
the function. Here is another test:
import std.stdio;
void foo() pure nothrow @nogc @safe
{}
void main()
{
void printInfo(T)(T t)
{
writefln("%s %s", T.str
On 05/14/2015 03:39 PM, Dennis Ritchie wrote:
On Thursday, 14 May 2015 at 21:55:40 UTC, Alex Parrill wrote:
On Thursday, 14 May 2015 at 00:39:25 UTC, Dennis Ritchie wrote:
On Thursday, 14 May 2015 at 00:33:33 UTC, Brian Schott wrote:
You told it to output a function literal, so it did.
Yes,
On Thursday, 14 May 2015 at 21:55:40 UTC, Alex Parrill wrote:
On Thursday, 14 May 2015 at 00:39:25 UTC, Dennis Ritchie wrote:
On Thursday, 14 May 2015 at 00:33:33 UTC, Brian Schott wrote:
You told it to output a function literal, so it did.
Yes, but it would be logical to deduce something lik
On Thursday, 14 May 2015 at 00:39:25 UTC, Dennis Ritchie wrote:
On Thursday, 14 May 2015 at 00:33:33 UTC, Brian Schott wrote:
You told it to output a function literal, so it did.
Yes, but it would be logical to deduce something like:
-
writeln({}); // prints literal[{}]
Or the compiler wi
On Thursday, 14 May 2015 at 20:32:28 UTC, rumbu wrote:
On Thursday, 14 May 2015 at 20:03:16 UTC, ivoras wrote:
What would be the difference between Array!string and string[]
?
std.array is used to manipulate or create built-in arrays from
various sources (ranges).
For basic needs, you can
On Thursday, 14 May 2015 at 18:42:56 UTC, Charles Hixson wrote:
What are the downsides to simulating a new type with a struct.
What I have in mind is something along the lines of:
struct myType
{ uint64_t value;
}
The goal of this type is to prevent accidental conversions from
myType into i
On Thursday, 14 May 2015 at 20:03:16 UTC, ivoras wrote:
What would be the difference between Array!string and string[] ?
std.array is used to manipulate or create built-in arrays from
various sources (ranges).
For basic needs, you can safely use built-in arrays:
http://dlang.org/arrays.htm
On Thursday, 14 May 2015 at 20:03:16 UTC, ivoras wrote:
Where would I look for documentation on the "~=" operator?
http://dlang.org/arrays.html
under the heading "array concatenation"
What would be the difference between Array!string and string[] ?
Array!string takes ownership of its own m
On Thursday, 14 May 2015 at 13:50:17 UTC, Adam D. Ruppe wrote:
On Thursday, 14 May 2015 at 13:26:27 UTC, ivoras wrote:
Is it resizable?
You can append with the ~= operator and size down by slicing it.
Apparently it doesn't even have an "insert" method:
http://dlang.org/phobos/std_array.html
On Thursday, 14 May 2015 at 19:00:16 UTC, tired_eyes wrote:
First, I don't understand why we see array[2] as 'Child'. While
it is a 'Child', shouldn't it be shown as a 'Parent' due to we
explicitly create an array of 'Parents'?
It is getting the name through a virtual interface (a hidden one
On Tuesday, 5 May 2015 at 07:41:04 UTC, sclytrack wrote:
On Monday, 4 May 2015 at 01:03:43 UTC, Fyodor Ustinov wrote:
On Saturday, 2 May 2015 at 20:46:32 UTC, Dennis Ritchie wrote:
On Saturday, 2 May 2015 at 19:38:01 UTC, Fyodor Ustinov wrote:
I see it by the lack of "42". :)
But why is this
Hi.
I'm having a hard time understanding D's inheritance. Consider
the following code:
class Parent {
public int x = 10;
}
class Child : Parent {
public int y = 20;
}
void main() {
import std.stdio;
Parent[] array;
auto obj1 = new Parent();
auto obj2 = new Child();
On 5/13/15 10:58 PM, rcorre wrote:
Actually, this doesn't even seem to work with a custom range:
import std.range;
import std.stdio;
import std.algorithm;
struct MyContainer {
@nogc auto opSlice() {
struct Range {
@property bool empty() { return true; }
What are the downsides to simulating a new type with a struct.
What I have in mind is something along the lines of:
struct myType
{ uint64_t value;
}
The goal of this type is to prevent accidental conversions from myType
into ints, uint64_ts, etc.
On Thursday, 14 May 2015 at 09:53:20 UTC, Per Nordlöw wrote:
I'm almost satisified with it except that the lazy evaluation at
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L45
cannot be made nothrow.
If I qualify the function as nothrow DMD complains as
algorithm_ex.d(45,16): Er
On Thursday, 14 May 2015 at 10:18:13 UTC, Maxim Fomin wrote:
On Thursday, 14 May 2015 at 09:53:20 UTC, Per Nordlöw wrote:
At
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L43
I've implemented a function either() with behaviour similar to
the `or` function/operator in dynamic lan
On Wednesday, 13 May 2015 at 11:24:10 UTC, Kagamin wrote:
On Tuesday, 12 May 2015 at 12:53:59 UTC, ponce wrote:
I already have such a dispose() function.
The problem is that to support Unique! and scoped! and
friends, the destructor must call dispose(). Thus my need for
a way to separate the G
On Thursday, 14 May 2015 at 10:46:53 UTC, Gerald Jansen wrote:
John Colvin's improvements to my D program seem to have
resolved the problem.
(http://forum.dlang.org/post/ydgmzhlspvvvrbeem...@forum.dlang.org
and http://dpaste.dzfl.pl/114d5a6086b7).
I have rerun my tests and now the picture is a
On Thursday, 14 May 2015 at 12:40:57 UTC, rcorre wrote:
So I thought this might work:
struct MaybeEmpty(R) if (isInputRange!R) {
private bool _isEmpty;
private R_input;
alias _input this;
this(bool isEmpty, R input) {
_input = input;
_isEmpty = isEmpty;
}
@property boo
On Thursday, 14 May 2015 at 12:42:01 UTC, ivoras wrote:
https://gist.github.com/ivoras/2d7737c214c3dc937c28
The crash is at line 20:
core.exception.AssertError@/usr/include/dmd/phobos/std/container/array.d(334):
[...]
This is on DMD32 D Compiler v2.067.1
Seems to be fixed in git head.
On Thursday, 14 May 2015 at 13:26:27 UTC, ivoras wrote:
Is it resizable?
You can append with the ~= operator and size down by slicing it.
Apparently it doesn't even have an "insert" method:
http://dlang.org/phobos/std_array.html .
http://dlang.org/phobos/std_array.html#insertInPlace
is the
On Thursday, 14 May 2015 at 13:26:27 UTC, ivoras wrote:
On Thursday, 14 May 2015 at 12:46:48 UTC, Adam D. Ruppe wrote:
I would just use a regular `string[]` array...
Is it resizable? Somehow I didn't get that impression from the
docs. Apparently it doesn't even have an "insert" method:
http:
On Thursday, 14 May 2015 at 12:46:48 UTC, Adam D. Ruppe wrote:
I would just use a regular `string[]` array...
Is it resizable? Somehow I didn't get that impression from the
docs. Apparently it doesn't even have an "insert" method:
http://dlang.org/phobos/std_array.html .
I would just use a regular `string[]` array...
What is the recommended dynamic array type in D? So far I found
Array (specifically Array!string, as I need a dynamic array of
strings), but my example program crashes:
https://gist.github.com/ivoras/2d7737c214c3dc937c28
The crash is at line 20:
core.exception.AssertError@/usr/include/dmd/pho
So I thought this might work:
struct MaybeEmpty(R) if (isInputRange!R) {
private bool _isEmpty;
private R_input;
alias _input this;
this(bool isEmpty, R input) {
_input = input;
_isEmpty = isEmpty;
}
@property bool empty() {
return _isEmpty || _input.empty;
}
}
a
On Thursday, 14 May 2015 at 06:41:45 UTC, Ali Çehreli wrote:
I am lucky because although the returned type is opaque to me,
I know that it is constructed by a void lambda.
Yeah, in this case I control the container so I may just add an
emptySlice property, but it does seem like it might be a
John Colvin's improvements to my D program seem to have resolved
the problem.
(http://forum.dlang.org/post/ydgmzhlspvvvrbeem...@forum.dlang.org
and http://dpaste.dzfl.pl/114d5a6086b7).
I have rerun my tests and now the picture is a bit different (see
tables below).
In the middle table I have
On Thursday, 14 May 2015 at 09:53:20 UTC, Per Nordlöw wrote:
At
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L43
I've implemented a function either() with behaviour similar to
the `or` function/operator in dynamic languages such as Python
and Lisp.
I'm almost satisified with
At
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L43
I've implemented a function either() with behaviour similar to
the `or` function/operator in dynamic languages such as Python
and Lisp.
I'm almost satisified with it except that the lazy evaluation at
https://github.com/nord
36 matches
Mail list logo