On Friday, 25 April 2014 at 11:51:48 UTC, bearophile wrote:
They are not the same type:
void main() {
import std.typecons: Tuple;
alias T1 = const Tuple!(int, int);
alias T2 = Tuple!(const int, const int);
static assert(is(T1 == T2)); // Fails.
}
This type difference causes
I'm trying to create a basic List type using Algebraic, but the
compiler keeps complaining about recursive aliasing.
import std.variant;
struct Cons(T, U: List)
{
public static opCall(T t, U u)
{
}
}
//Error
alias List = Algebraic!(typeof(null), Cons!(int, This));
On Sunday, 27 April 2014 at 20:22:12 UTC, bearophile wrote:
Meta:
I'm trying to create a basic List type using Algebraic, but
the compiler keeps complaining about recursive aliasing.
As stated in its docs, Algebraic is not yet finished and good
for recursive data structures. But here I have
On Sunday, 27 April 2014 at 20:38:37 UTC, Meta wrote:
Is it necessary to use This[]? I tried changing it to This* and
it blew up on me.
I should specify. This did not work:
alias T = Algebraic!(int, This*);
void main() {
auto l = T(1, new T(2, new T(3, null)));
}
On Sunday, 27 April 2014 at 20:28:28 UTC, bearophile wrote:
Meta:
alias List = Algebraic!(typeof(null), Cons!(int, This));
Also your Cons seems a value type, like Algebraic itself. You
have to avoid creating an infinite-size algebraic value.
Bye,
bearophile
Yes, it's hard to figure out
On Sunday, 27 April 2014 at 20:54:02 UTC, bearophile wrote:
An Algebraic is a sum type, so you can't store two value in it,
only one, an int or a T*. But this is not going to solve your
problems...
Bye,
bearophile
Ah, you're right. I'm getting mixed up from my own initial
example. Fiddling
On Tuesday, 29 April 2014 at 16:52:27 UTC, Ali Çehreli wrote:
That may be misleading because there is no need to allocate
with an explicit new. For example, the slice below is owned by
the GC as well:
int[] foo()
{
int[] a;
a ~= 42;// on memory owned by the GC
return a;
}
I
On Friday, 2 May 2014 at 13:38:39 UTC, Nordlöw wrote:
enums.d(25,46): Error: static variable allMembers cannot be
read at compile time
enums.d(25,21):while evaluating: static assert(a in
allMembers)
Is there a solution to this problem?
Associative arrays are not CTFE-able.
On Friday, 2 May 2014 at 15:18:06 UTC, Artur Skawina via
Digitalmars-d-learn wrote:
On 05/02/14 15:38, Nordlöw via Digitalmars-d-learn wrote:
template MemberNamesUnion(E...) if (allSatisfy!(isEnum, E))
{
bool[string] allMembers; // used to detect member
collisions
mixin({
On Friday, 2 May 2014 at 21:29:51 UTC, Mark Isaacson wrote:
Auto ref parameters seem to be just what I need. Thanks! I'd
still be curious if anyone has additional information regarding
the rationale at play (I'm spoiled, reading TDPL and having
each decision explained in text).
The C++ way
You could replace all those `op=='+'||op=='-'? ...` with
`op.among!('+', '-')? ...`.
On Monday, 5 May 2014 at 04:05:35 UTC, Mark Isaacson wrote:
Something like:
unittest {
enum offsetof(string type, string field) = mixin(type ~ . ~
field ~ .offsetof);
struct StrToBob {
string str;
int bob;
}
writeln(offsetof!(StrToBob, bob));
}
?
If not that then I'm not
On Wednesday, 7 May 2014 at 13:25:55 UTC, bearophile wrote:
So far in Rosettacode D entries I've kept a line length limit
of 72 or 73 chars.
But now a little larger monitors are common, D UFCS chains are
common, and we also have longer function signatures with pure
nothrow @safe @nogc (that
On Wednesday, 7 May 2014 at 18:51:59 UTC, Meta wrote:
On Wednesday, 7 May 2014 at 14:40:37 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
My eyes... Oh, how that hurts readibily.
While I agree that
pure @safe @nogc nothrow
void doSomething(int n)
{
}
is quite ugly, it is really not
On Friday, 9 May 2014 at 01:02:39 UTC, FrankLike wrote:
Hi,everyone,
down VisulaD from
http://rainers.github.io/visuald/visuald/StartPage.html
found the virus:Win32.Troj.Undef.(kcloud)
Why?
Frank
I've been using VisualD for a long time without problems. If it
makes you nervous, you can
On Saturday, 10 May 2014 at 08:42:14 UTC, FrankLike wrote:
I've been using VisualD for a long time without problems. If
it makes you nervous, you can get the source from Github and
compile it yourself.
Hello,Meta
When I compile the Visual D projects:
at first,I compile the 'build'
On Saturday, 10 May 2014 at 10:56:57 UTC, Jacob Carlborg wrote:
I know that there are templates to inspect function parameters,
like ParameterIdentifierTuple and ParameterTypeTuple. But these
don't work for templated/untyped lambdas, they're apparently
not callables. I don't expect
On Wednesday, 14 May 2014 at 22:32:01 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
Yeah, much as Andrei would hate to hear it (enforce was his
idea, and he quite
likes the idiom), the fact that lazy is so inefficient makes it
so that it's
arguably bad practice to use it in high
On Sunday, 18 May 2014 at 04:19:05 UTC, David Held wrote:
How do I get an array from randomSample()?
int[] source = [ ... ];
int[] sample = randomSample(source, 3);
src\main.d(30): Error: cannot implicitly convert expression
(randomSample(source, 3u)) of type RandomSample!(int[], void)
to
On Friday, 23 May 2014 at 15:14:47 UTC, Chris wrote:
The following:
import std.stdio;
void main() {
int[5] arg;
arg[10] = 3; // Compiler says (of course):
Error: array index 10 is out of bounds arg[0 .. 5]
}
import std.stdio;
void main() {
int[5] arg;
foreach (i;
I'd like to get a list of all classes in the current module, so I
came up with this code:
class Test {}
class TestChild: Test {}
class TestChildChild: TestChild {}
void main()
{
foreach (item; __traits(allMembers, mixin(__MODULE__)))
{
static if
On Thursday, 29 May 2014 at 23:18:32 UTC, Dicebot wrote:
class Test {}
class TestChild: Test {}
class TestChildChild: TestChild {}
alias Alias(alias Symbol) = Symbol; // this does the trick
void main()
{
foreach (item; __traits(allMembers, mixin(__MODULE__)))
{
alias sym =
On Monday, 2 June 2014 at 22:18:39 UTC, bioinfornatics wrote:
Hi,
I would like store the delegate to another var but when i try i
get:
testTraitsWithDelegate.d(13): Error: expression template
__lambda2 is void and has no value
I do not want to run it only to save the «function» somewhere.
On Thursday, 5 June 2014 at 07:19:07 UTC, timotheecour wrote:
ok I remembered we can use std.typetuple.Alias for that.
Or std.functional.unaryFun.
On Friday, 6 June 2014 at 14:25:26 UTC, hane wrote:
On Friday, 6 June 2014 at 12:01:55 UTC, AntonSotov wrote:
const r1 = regex(bla);
matchFirst( big string, r1 ); // ERROR!
immutable r2 = regex(bla); // ERROR!
Why can I not use const/immutable regex?
I think it's a Phobos bug that can't
On Saturday, 7 June 2014 at 00:48:59 UTC, hane wrote:
On Friday, 6 June 2014 at 15:42:41 UTC, Meta wrote:
You should not do this, as it will create a new regex
everywhere you use it. Unlike const or immutable, enum in this
situation is more or less like a C macro.
#define r1 regex(bla)
I
On Saturday, 7 June 2014 at 16:15:47 UTC, hane wrote:
At std.regex.
BTW, I found that immutable regex can be created with enum.
enum r1_ = regex(bla);
immutable r1 = r1_;
Regex struct created during compiling can be immutable?
In this case, it must be using enum to force CTFE. As for
I thought this was possible, but DMD 2.065 doesn't allow it,
saying no constructor for int:
int* p = new int(3);
Is something like this planned for the future? I know we can
already do:
int n = int(3);
On Saturday, 14 June 2014 at 06:39:56 UTC, Ali Çehreli wrote:
On 06/13/2014 10:29 PM, Meta wrote:
I thought this was possible, but DMD 2.065 doesn't allow it,
saying no
constructor for int:
int* p = new int(3);
Is something like this planned for the future? I know we can
already do:
int n
On Monday, 23 June 2014 at 22:11:57 UTC, John Carter wrote:
On Monday, 23 June 2014 at 21:49:29 UTC, Ary Borenszweig wrote:
Union types are very common (I use them every day), and IMHO
it's very nice to have them included in the language (either
built-in or as a library solution). As a
On Tuesday, 24 June 2014 at 10:11:05 UTC, bearophile wrote:
I don't think it's solved. There are probably bugs worth
reporting here.
I have not found them, sorry for the noise.
Bye,
bearophile
This looks really bad. I thought we weren't going to allow
variable templates, just enums and
On Wednesday, 25 June 2014 at 09:30:54 UTC, seany wrote:
Given an assosiative array : int[string] k, is there a way
(either phobos or tango) to pop the first element of this array
and append it to another array?
I can come up with a primitive soluiton:
int[string] k;
// populate k here
On Wednesday, 25 June 2014 at 20:17:35 UTC, rcor wrote:
I'm trying to create a set of utility functions that cache
objects of various types loaded from json files, but having
trouble testing it. One function I'd like to test uses new to
instantiate an object based on a compile-time parameter:
On Thursday, 26 June 2014 at 09:21:28 UTC, seany wrote:
On Wednesday, 25 June 2014 at 14:17:50 UTC, Meta wrote:
If you want something like a hash table that preserves
insertion order, you could try using an array of tuples
instead. Then to pop the first element, just do 'arr =
arr[1..$]'.
On Thursday, 26 June 2014 at 07:11:03 UTC, Uranuz wrote:
But if I write
@(hello) struct Hello {}
so all of the variables that have type Hello will have
attribute @(hello) like come type qualifier because attribute
is a part of declaration of Hello. Do I understand correctly?
No, it is only
On Monday, 7 July 2014 at 12:06:21 UTC, Frédérik wrote:
Hi all,
I'm discovering the D language that seems very nice in many
aspects, but I'm quite confused by the container and range APIs
while trying to design a very simple interface-oriented API.
Especially I can't figure out how
On Monday, 7 July 2014 at 09:53:22 UTC, NCrashed wrote:
I am using ranges (wrapped in InputRangeObject for use in
interfaces) of shared objects, with new beta some cases are
broken:
```
import std.range;
class A {}
InputRange!(shared A) foo()
{
return [new A].inputRangeObject;
}
On Monday, 7 July 2014 at 19:20:24 UTC, Fr wrote:
It's in the example above :
SortedRange!(MyObject[]) opSlice() {
sequence[].array.assumeSorted; }
I thought that that using .array would lead to instantiating
something.
Yes, this *will* instantiate an array and copy all of the items
from
On Tuesday, 8 July 2014 at 12:42:44 UTC, NCrashed wrote:
Oops, I forgot shared at new. But the major issue is that
doesn't fix the problem:
```
import std.range;
class A {}
InputRange!(shared A) foo()
{
return [new shared A].inputRangeObject;
}
void bar()
{
auto res =
On Tuesday, 8 July 2014 at 17:42:00 UTC, Remo wrote:
How to make something that work like std::tie in D2 ?
Tuple!(float, float) sinCos(float n) {
return tuple(cast(float)sin(n), cast(float)cos(n)); //please
note cast(float)!
}
int main(string[] argv) {
float s,c;
tie!(s,c) =
On Tuesday, 8 July 2014 at 18:45:21 UTC, Remo wrote:
On Tuesday, 8 July 2014 at 18:29:40 UTC, Meta wrote:
On Tuesday, 8 July 2014 at 17:42:00 UTC, Remo wrote:
How to make something that work like std::tie in D2 ?
Tuple!(float, float) sinCos(float n) {
return tuple(cast(float)sin(n),
On Monday, 7 July 2014 at 23:47:26 UTC, Aerolite wrote:
Hey all,
I've not posted here in a while, but I've been keeping up to
speed with D's progress over the last couple of years and
remain consistently impressed with the language.
I'm part of a new computing society in the University of
On Sunday, 13 July 2014 at 11:18:05 UTC, bearophile wrote:
The idea of not making std.algorithm.among!() a predicate was
not so good:
void main() {
import std.stdio, std.algorithm;
auto s = hello how\nare you;
s.until!(c = c.among!('\n', '\r')).writeln;
}
(A normal workaround is
On Sunday, 13 July 2014 at 19:06:29 UTC, Timon Gehr wrote:
On 07/13/2014 08:51 PM, Meta wrote:
That's weird, I always assumed this worked. Was it always the
case that
numeric types can't be implicitly casted to bool?
Yes, unless their range fits into [0,2).
It seems that not even that is
On Tuesday, 15 July 2014 at 15:48:10 UTC, Puming wrote:
wow, that's interesting :-) Is it the idiomatic approach to
initiate immutable objects lazily? Or do people use data class
with immutable fields and generate a companion builder class at
compile time?
There's no real idiomatic approach,
On Tuesday, 15 July 2014 at 10:22:52 UTC, rumbu wrote:
getch() reads any key and continues;
On Windows you can pipe you executable with the more command
to pause after each page: your.exe | more
Don't forget that getch() is also Windows-specific.
On Tuesday, 15 July 2014 at 16:04:26 UTC, bearophile wrote:
Alexandre:
mapstring, Address syms;
If you don't need the key ordering then use a built-in
associative array:
Address[string] syms;
Otherwise use a RedBlackTree from std.container.
vectorpairDWORD, Address values;
On Thursday, 17 July 2014 at 13:40:20 UTC, bearophile wrote:
Meta:
For `Tuple!(DWORD, DWORD*)[] addrs;`, DWORD* is not same as
shared_ptrDWORD. It's important to keep that in mind.
OK. How do you suggest to translate it in D?
Bye,
bearophile
I don't know. I just wanted to make sure OP
On Saturday, 26 July 2014 at 00:26:08 UTC, Ary Borenszweig wrote:
Or use Algebraic, but it currently doesn't support recursive
type definitions.
Algebraic does support recursive type definitions.
import std.variant;
alias Rec = Algebraic!(int, This*);
void main()
{
//I'm not sure why
On Saturday, 26 July 2014 at 20:49:30 UTC, seany wrote:
Can a function return a function in D? Sorry if i missed the
answer somewhere
Yup, you can return functions, delegates, or function pointers.
int function(int) returnsFunc1()
{
return function(int n) { return n; };
}
int
On Wednesday, 6 August 2014 at 07:23:32 UTC, Rikki Cattermole
wrote:
The magic of with statements!
enum A {
a1,
a2
}
void func(A a){}
void main(){
func(A.a1);
with(A) {
func(a1);
}
}
And if you want to be *really* concise:
with (A)
On Saturday, 9 August 2014 at 01:20:33 UTC, Vlad Levenfeld wrote:
More opDispatch woes. This feature keeps biting me, yet I keep
trying to use it.
This time I'm trying to access elements of a vector GLSL-style
(without swizzling... for now).
Here's the relevant code:
struct Vector (uint
On Saturday, 9 August 2014 at 16:39:34 UTC, Vlad Levenfeld wrote:
I may be misunderstanding the intended semantics of the []
operator but I've come to interpret x[] to mean give me x as a
range and this is the meaning I intend when I overload it in
my own structs.
But -
auto z = tuple
On Saturday, 9 August 2014 at 20:32:05 UTC, Vlad Levenfeld wrote:
Are there any specific cases where they're not?
Not that I know of, and it doesn't really make sense for them not
to be, but it could happen. If you want to be certain that
slicing a type will produce a valid range, you can do
On Tuesday, 12 August 2014 at 06:37:45 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
The problem is that isNaN is now templatized, and its
constraint uses
isFloatingPoint, which requires that the type _be_ a floating
point type, not
that it implicitly convert to one. So, as it stands,
On Tuesday, 12 August 2014 at 14:26:46 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
AFAIK, the only time that the implicit conversion would take
place is when the
type is being used in a situation where it doesn't work
directly but where the
aliased type is used. In that case, the
On Wednesday, 13 August 2014 at 12:37:34 UTC, Nordlöw wrote:
Are there variants of drop* and take* that only drop element if
its equal to a value kind of like strip does?
If not I believe they should be added.
No, but it'd probably be useful. Maybe call them dropIf/takeIf,
or just add an
On Wednesday, 20 August 2014 at 01:38:53 UTC, uri wrote:
Hi all,
Bit new to D so this might be a very naive question...
Can the compiler auto infer function attributes?
I am often adding as many attributes as possible and use the
compiler to show me where they're not applicable and take them
Something weird happens when I try to foreach over test.tupleof.
If the foreach loop has 2 variables like so:
struct Test
{
string name = 'null';
int id;
}
void main()
{
auto test = Test();
assert(test.name == 'null');
assert(test.id == 0);
On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote:
What is happening here? Are these two extra ulongs the offsets
of the fields in the struct?
And I just realized that that's obviously not the case. It's just
an iteration variable. Problem solved.
On Saturday, 23 August 2014 at 01:56:06 UTC, Dicebot wrote:
On Saturday, 23 August 2014 at 01:32:13 UTC, Meta wrote:
On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote:
What is happening here? Are these two extra ulongs the
offsets of the fields in the struct?
And I just realized that
On Saturday, 23 August 2014 at 20:34:35 UTC, Ali Çehreli wrote:
There are a number of inconsistencies around tuples. The
behavior you expect is present for ranges that return tuple
fronts:
import std.stdio;
import std.typecons;
import std.range;
void main()
{
auto t = [ tuple(1.5, 100),
On Sunday, 24 August 2014 at 23:20:21 UTC, maik klein wrote:
On Sunday, 24 August 2014 at 21:51:39 UTC, Weaseldog wrote:
On Sunday, 24 August 2014 at 20:32:02 UTC, maik klein wrote:
Are there any exercises/challenges for D?
Something like this?
On Tuesday, 26 August 2014 at 01:57:06 UTC, Meta wrote:
Have you heard of Project Euler? https://projecteuler.net/
The problems are mostly mathematical, and once you answer you
can compare your solution to the other solutions people have
written in other languages. The early questions also
On Wednesday, 3 September 2014 at 19:43:26 UTC, Nordlöw wrote:
Is there a simpler way to way to
s ~= repeat('*', n).array.to!string;
if s has to be of type string?
Does this work?
s ~= *.replicate(n);
On Wednesday, 3 September 2014 at 20:20:09 UTC, Meta wrote:
On Wednesday, 3 September 2014 at 19:43:26 UTC, Nordlöw wrote:
Is there a simpler way to way to
s ~= repeat('*', n).array.to!string;
if s has to be of type string?
Does this work?
s ~= *.replicate(n);
Sorry, I should qualify
On Thursday, 11 September 2014 at 14:49:03 UTC, bearophile wrote:
void main() {
//...
immutable ar2 = [Thing(10), Thing(20), Thing(40)];
ar2.minimum.writeln;
}
Bye,
bearophile
Even better:
void main
{
immutable(Thing)[] ar2 = [10, 20, 40];
On Thursday, 11 September 2014 at 21:28:59 UTC, Colin wrote:
Using the alias x this solution would work, but my actual
struct is not a simple struct, so the comparison isn't exactly
(a.x b.x).
You could always override opCmp as well:
http://dlang.org/operatoroverloading.html#compare
I think this is just a language oversight. It's allowed in if
statements, and people have made a good case for allowing it for
switch statements. It just hasn't been implemented. I made an
attempt one evening to implement it for switch statements, but
I'm not at all familiar with DMD, so I
This happens with a freshly checked out master. I first build
DMD, which completes successfully. However, when I then try to
build Druntime, I got the following error messages:
src\core\stdc\wchar_.d(32): Error: undefined identifier FILE
src\core\stdc\wchar_.d(33): Error: undefined identifier
On Saturday, 27 September 2014 at 11:26:33 UTC, ponce wrote:
I'm dabbling with Scheme interpreter and ultimately I would
need to declare the following types.
--
struct Function
{
Environment env;
Atom params;
Atom body_;
}
// An atom is either a string, a double, a
On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote:
Is there a reason why isArray!T doesn't match T when T is a
std.container.Array? I'm asking because after looking into
msgpack-d because of
On Sunday, 28 September 2014 at 19:11:23 UTC, Jay wrote:
i want to chain 'new' with method calls on the created object.
i found this on the internet:
window.mainWidget = (new Button()).text(Hello
worldd).textColor(0xFF);
it would look much nicer with UFCS:
window.mainWidget =
On Sunday, 28 September 2014 at 20:50:07 UTC, Jay wrote:
On Sunday, 28 September 2014 at 20:30:42 UTC, Meta wrote:
class Button
{
typeof(this) text(string t)
{
return this;
}
typeof(this) textColour(int c)
{
return
On Wednesday, 15 October 2014 at 16:48:24 UTC, Laeeth Isharc
wrote:
Hi.
I have to write a bunch of functions that operate on input
arrays to return multiple output arrays.
In case helpful the inputs are price bars or economic data
points (datetime, ohlc) and the outputs are nx1 arrays (I
On Wednesday, 15 October 2014 at 17:56:06 UTC, Ali Çehreli wrote:
- Unlike a struct, the members are anonymous. (Yes, tuples
members can have names as well but not when returning or
creating conveniently by 'return tuple(a, b)'.)
This works, but I agree it is a bit obscure (you may want to
On Saturday, 18 October 2014 at 23:51:53 UTC, tcak wrote:
enum Values: string{
NONE = ,
Value1 = Apple,
Value2 = Peach,
Value3 = Lemon
}
Values lastHeldValue = Value3;
Is the lastHeldValue just pointer + length information, and
it
points to Lemon; or is Lemon copied to another place
On Tuesday, 21 October 2014 at 16:56:06 UTC, Solomon E wrote:
On Tuesday, 21 October 2014 at 15:51:27 UTC, MachineCode wrote:
...
...
pure functions are also supposed to don't use global variables
at all, according to functional programming paradigm
Pure functions are immutables (constants
On Friday, 31 October 2014 at 00:17:02 UTC, Samuel Pike wrote:
Hi all.
First time posting here. I recently downloaded the dmd compiler
and started making a few exercises with the language. Nice
language features but still somewhat confused with the library.
If I use byDchar() over a string
On Friday, 31 October 2014 at 02:01:00 UTC, Paul O'Neil wrote:
I'm trying to bind to some C++ code, but when I compile the D
side,
there are errors. Here's my reduced test case:
// C++
namespace ns {
void func1();
void func2();
}
// D
module cpp;
extern(C++, ns) void func1();
On Friday, 31 October 2014 at 23:22:50 UTC, Paul O'Neil wrote:
Thanks for the response. That does work.
Should I file a bug report or create a PR for the docs?
It might be a good idea to create a thread in DigitalMars.D to
get clarification on the intended behaviour. A doc PR never hurts
On Saturday, 1 November 2014 at 23:18:35 UTC, John Colvin wrote:
Doesn't support is keyword.
Another good use-case for allowing a user-defined operator for is.
On Monday, 3 November 2014 at 17:05:21 UTC, John Colvin wrote:
static if (is(typeof(T) == int))
should be
static if (is(T == int))
T is already a type.
I thought this was supposed to produce an error message rather
than fail silently... I'm positive this used to be an error. Did
it
This is the code for std.range.put:
void put(R, E)(ref R r, E e)
{
//Why?
@property ref E[] EArrayInit(); //@@@9186@@@: Can't use
(E[]).init
//First level: simply straight up put.
static if (is(typeof(doPut(r, e
{
doPut(r, e);
}
//Optional optimization
On Thursday, 6 November 2014 at 21:57:36 UTC, Steven
Schveighoffer wrote:
github blame is quite useful:
https://github.com/D-Programming-Language/phobos/blame/master/std/range.d#L668
The commit:
https://github.com/D-Programming-Language/phobos/commit/c717b503e7305a92410c23ca2bc2ea14b40f8aa2
Say I have the following struct and object definitions:
struct Test1(T)
{
static if (???)
{
void doSomething()
{
writeln(typeof(this).stringof);
}
}
T t;
}
class Test2(T)
{
static if (???)
{
void doSomething()
{
One other thing. I know about `template this`, but I'm not sure
if that's a tenable solution or not in my case. In addition to
templating the struct or class, would I not also have to template
the constructor so it could pick up the type of `this` at the
declaration site?
On Sunday, 9 November 2014 at 16:31:46 UTC, bearophile wrote:
H. S. Teoh:
It's only a bad idea because people abuse assert() where it's
not appropriate.
It's a bad idea because Walter seems unable to understand the
difference between verifying and proving.
Bye,
bearophile
On the other
On Saturday, 15 November 2014 at 00:33:11 UTC, Nordlöw wrote:
Is there a functional variant of std.algorithm.sort, say
sorted, that returns a sorted copy of its input use typically as
const y = x.sorted;
?
If not any recommendations on its implementation?
`sort` returns a SortedRange,
On Saturday, 15 November 2014 at 00:45:11 UTC, Meta wrote:
On Saturday, 15 November 2014 at 00:33:11 UTC, Nordlöw wrote:
Is there a functional variant of std.algorithm.sort, say
sorted, that returns a sorted copy of its input use typically
as
const y = x.sorted;
?
If not any
On Saturday, 15 November 2014 at 00:47:41 UTC, Nordlöw wrote:
On Saturday, 15 November 2014 at 00:45:11 UTC, Meta wrote:
`sort` returns a SortedRange, so sort is the function you're
looking for.
Do you mean std.algorithm.sort?
I want a sort that doesn't mutate its input argument.
In that
On Saturday, 15 November 2014 at 01:01:57 UTC, Nordlöw wrote:
On Saturday, 15 November 2014 at 00:47:57 UTC, Meta wrote:
`sort` returns a SortedRange, so sort is the function you're
looking for.
Sorry, and if you want a copy, just add a `.array` on the end
to create a new array from the
On Saturday, 15 November 2014 at 03:47:25 UTC, Steven
Schveighoffer wrote:
err... this isn't what you want. That will sort the range, and
then make a copy of the sorted range as an array.
Yes, I didn't see the the second constraint to not sort the
original range.
Sort before .array -
That's a neat trick, although if preconditions were able to be
run at compile time when possible you wouldn't have to resort to
using enum to force CTFE (you've talked a bit about this before I
remember). Thinking about something like a good ranged number
implementation, we can now get almost
On Wednesday, 26 November 2014 at 05:24:49 UTC, Bear Cherian
wrote:
I ran into this a while ago and have already moved on, but I
had a class such as this
Class MyClass{
this(){}
void someFunction(){
//body
}
}
And in my app I had something like
MyClass classObject;
On Saturday, 29 November 2014 at 11:07:34 UTC, Sly wrote:
On Saturday, 29 November 2014 at 09:11:51 UTC, Ali Çehreli
wrote:
Point!T getResponse(P : Point!T, T)(string question)
{
// ...
}
This doesn't work because now this definition has 2 parameters P
and T. I have to specify both like
On Saturday, 29 November 2014 at 18:19:40 UTC, Sly wrote:
You miss another definition which introduces a conflict:
T getResponse(T)(string question)
{...}
In that case, you're better off with a pair of declarations:
struct Point(T)
{
T x;
T y;
}
T getResponse(T)(string
On Sunday, 30 November 2014 at 19:24:39 UTC, Suliman wrote:
I can't understand why I am getting exception on next code:
void downloadFile()
{
foreach(link; links)
{
try
{
On Tuesday, 2 December 2014 at 16:38:34 UTC, Mayuresh Kathe wrote:
While I have been a programmer for close to 23 years, it's been
mostly API level code cobbling work.
Would like to learn D, but am a bit intimidated by the fact
that I don't have much of a grasp over the foundational stuff
On Sunday, 14 December 2014 at 18:41:54 UTC, MachineCode wrote:
The labels are disabled then? I find that goto case case_value
ugly and prefer goto labelName; but if it's the only way to go
let's do it
I'm not sure if it's intentionally not supported, or just an
oversight. Probably the
1 - 100 of 434 matches
Mail list logo