I need to ensure that range passed to function is SortedRange to use
binary search. I did something like:
static if(!__traits(compiles,
{
ElementType!(typeof(data)) element;
auto d = data.trisect(element);
}
)) assert(0, DataRange shall be
http://dlang.org/phobos/std_traits.html#TemplateOf
On Wednesday, 20 August 2014 at 07:18:12 UTC, Kagamin wrote:
http://dlang.org/phobos/std_traits.html#TemplateOf
Or isInstanceOf.
static if (__traits(isSame, TemplateOf!R, SortedRange))
static if (isInstanceOf!(SortedRange, R))
Thank you!
On Wed, 20 Aug 2014 01:38:52 +
uri via Digitalmars-d-learn digitalmars-d-learn@puremagic.com 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
On Wednesday, 20 August 2014 at 09:13:15 UTC, Jonathan M Davis
via Digitalmars-d-learn wrote:
On Wed, 20 Aug 2014 01:38:52 +
uri via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
Hi all,
Bit new to D so this might be a very naive question...
Can the compiler auto infer
I've been hearing that delegates get a context pointer which will be
allocated on the GC. Is this also true for delegates which stay in scope?
e.g.
void addThree() {
int val;
void addOne() {
val++;
}
addOne();
addOne();
On Wed, 20 Aug 2014 10:44:38 -0400
Etienne via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
Will the above function allocate on the GC?
no.
signature.asc
Description: PGP signature
I have several times seen a construct
template foo(T...) if(T.length == 1)
{
...
}
What is that good for?
Why using variadic parameter if anyway exactly one parameter is
required?!?
non-static nested functions are effectively delegates as it
needs a context pointer to parent stack frame.
Only if it is recursive.
On Wednesday, 20 August 2014 at 14:44:39 UTC, Etienne wrote:
I've been hearing that delegates get a context pointer which
will be allocated on the GC. Is this also true for delegates
which stay in scope?
e.g.
void addThree() {
int val;
void addOne() {
val++;
On Wednesday, 20 August 2014 at 15:11:53 UTC, Dominikus Dittes
Scherkl wrote:
I have several times seen a construct
template foo(T...) if(T.length == 1)
{
...
}
What is that good for?
Why using variadic parameter if anyway exactly one parameter is
required?!?
AFAIK, it's a historical
On Wednesday, 20 August 2014 at 15:26:14 UTC, monarch_dodra wrote:
AFAIK, it's a historical workaround to accept T as either alias
or not alias, as varargs have auto alias. EG:
foo!int //OK
foo!hello //OK too
Ah, ok.
And why historical? Is that not necessary anymore? What better
solution is
On Wednesday, 20 August 2014 at 15:11:53 UTC, Dominikus Dittes
Scherkl wrote:
I have several times seen a construct
template foo(T...) if(T.length == 1)
{
...
}
What is that good for?
Why using variadic parameter if anyway exactly one parameter is
required?!?
That's because template
On Wed, Aug 20, 2014 at 5:34 PM, Dominikus Dittes Scherkl via
Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:
On Wednesday, 20 August 2014 at 15:26:14 UTC, monarch_dodra wrote:
AFAIK, it's a historical workaround to accept T as either alias or not
alias, as varargs have auto
On Wednesday, 20 August 2014 at 15:37:18 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:
No better solution that I know of.
alias template parameters (alias a) match symbols (names,
user-defined
types) whereas type parameter (T) match only pure types.
So when we need to match anything,
Hello,
I'm trying to follow the documentation:
http://dlang.org/phobos/std_process.html#.execute
Unfortunately, the following code gives me a compiler error:
class Probator
{
char[] dir;
this(const char[] dir){
this.dir = dir.dup;
}
int
On Wed, 20 Aug 2014 16:07:47 +
KrzaQ via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:
It's as if the implementation didn't expect the last argument.
try to upgrade to dmd 2.066.
signature.asc
Description: PGP signature
On Wednesday, 20 August 2014 at 16:16:03 UTC, ketmar via
Digitalmars-d-learn wrote:
On Wed, 20 Aug 2014 16:07:47 +
KrzaQ via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
It's as if the implementation didn't expect the last argument.
try to upgrade to dmd 2.066.
That
On Wednesday, 20 August 2014 at 15:34:30 UTC, Dominikus Dittes
Scherkl wrote:
And why historical? Is that not necessary anymore? What better
solution is there today?
Historical in a sense that distinct can be anything template
parameter is probably a better approach but it is too late to
On Wednesday, 20 August 2014 at 17:02:59 UTC, Dicebot wrote:
On Wednesday, 20 August 2014 at 15:34:30 UTC, Dominikus Dittes
Scherkl wrote:
And why historical? Is that not necessary anymore? What better
solution is there today?
Historical in a sense that distinct can be anything template
Hi,
I'm implementing some template checks on some types I'm using in
a project, and went to phobos for some indications on how to use
them.
In std.range, I see this construct quite a bit:
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R
On Wed, 20 Aug 2014 20:01:03 +, Colin wrote:
It looks veryhacky.
I see 3 distinct parts playing a role in my confusion:
A) The 'is' keyword. What does it do when you have is(expression);
B) typeof( expression ); whats this doing? Particularly when the
expression its acting on is a
On Wednesday, 20 August 2014 at 20:01:05 UTC, Colin wrote:
I see 3 distinct parts playing a role in my confusion:
A) The 'is' keyword. What does it do when you have
is(expression);
http://dlang.org/expression.html#IsExpression
It is a tool for type checking. It has many options but plain
#!/usr/bin/gdc
import std.stdio;
void main()
{
writeln(Hello, world with automated script running!);
}
When I compile the code above normal to an a.out binary it runs
like expected. But running it with shebang it does nothing. No
output, especially no error message. Nothing.
What do I
On Wednesday, 20 August 2014 at 20:21:13 UTC, anonymous wrote:
On Wednesday, 20 August 2014 at 20:17:49 UTC, Newbie wrote:
#!/usr/bin/gdc
import std.stdio;
void main()
{
writeln(Hello, world with automated script running!);
}
When I compile the code above normal to an a.out binary it runs
On Wednesday, 20 August 2014 at 20:17:49 UTC, Newbie wrote:
#!/usr/bin/gdc
import std.stdio;
void main()
{
writeln(Hello, world with automated script running!);
}
When I compile the code above normal to an a.out binary it runs
like expected. But running it with shebang it does nothing. No
On Wednesday, 20 August 2014 at 20:12:58 UTC, Justin Whear wrote:
On Wed, 20 Aug 2014 20:01:03 +, Colin wrote:
It looks veryhacky.
I see 3 distinct parts playing a role in my confusion:
A) The 'is' keyword. What does it do when you have
is(expression);
B) typeof( expression ); whats
Re-compiling existing code with version 2.066 generates a lot of
errors complaining about implicit conversion to const. Typical is
this call (inside a struct with properties 1 2):
z.sign = x.sign ^ y.sign;
Error: None of the overloads of 'sign' are callable using
argument types bool
On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr
wrote:
non-static nested functions are effectively delegates as it
needs a context pointer to parent stack frame.
Only if it is recursive.
Or if it refers to any state of the parent function.
gdc just compiles the program to a.out. It doesn't run the
resulting executable. You need to use something like rdmd instead
of gdc. rdmd compiles to some temporary location and then runs
the executable.
Wow, that was fast. Thanks a lot!
Can compiler switches be used with the shebang
On Wednesday, 20 August 2014 at 20:39:42 UTC, Jonathan M Davis
wrote:
is(typeof(foo)) and __traits(compiles, foo) are not the same.
The first tests for the existence of the symbol, whereas the
second checks whether the code will actually compile.
Is that even true? I mean, are you just
On Wednesday, 20 August 2014 at 20:48:38 UTC, Chris
Nicholson-Sauls wrote:
On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr
wrote:
non-static nested functions are effectively delegates as it
needs a context pointer to parent stack frame.
Only if it is recursive.
Or if it refers
On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson
wrote:
Re-compiling existing code with version 2.066 generates a lot
of errors complaining about implicit conversion to const.
Typical is this call (inside a struct with properties 1 2):
z.sign = x.sign ^ y.sign;
Error:
On Wednesday, 20 August 2014 at 21:19:18 UTC, Ola Fosheim Gr
wrote:
On Wednesday, 20 August 2014 at 20:48:38 UTC, Chris
Nicholson-Sauls wrote:
On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr
wrote:
Only if it is recursive.
Or if it refers to any state of the parent function.
On 2014-08-20 5:25 PM, Ola Fosheim Gr wrote:
Well, I guess simple recursion could be solved easily too by having a
wrapper function that puts the frame pointer in a free callee save
register...
So, my question inspired a new optimization? :-p
On Wednesday, 20 August 2014 at 21:06:49 UTC, monarch_dodra wrote:
On Wednesday, 20 August 2014 at 20:39:42 UTC, Jonathan M Davis
wrote:
is(typeof(foo)) and __traits(compiles, foo) are not the same.
The first tests for the existence of the symbol, whereas the
second checks whether the code
On Wednesday, 20 August 2014 at 21:30:41 UTC, Etienne wrote:
So, my question inspired a new optimization? :-p
A decent optimizing compiler would detect that the function is
calling itself and save stack space by using register where
possible...
Hello, I've been very interested about the announce saying that
DMD is able to produce COFF object files. Mostly because I'm
thinking using some objects programmed in D in a software
programmed in another lang, a bit like when statically linking a
dll to a program but with an obj, to keep a
On Wednesday, 20 August 2014 at 23:56:23 UTC, Baz wrote:
Hello, I've been very interested about the announce saying that
DMD is able to produce COFF object files. Mostly because I'm
thinking using some objects programmed in D in a software
programmed in another lang, a bit like when statically
On Wed, 20 Aug 2014 17:47:36 +
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Yeah, what he said. It's a language artifact.
by the way, it would be nice to have wiki page with such artifacts and
their explanations.
signature.asc
Description: PGP signature
On Wed, 20 Aug 2014 23:03:48 +0200
Philippe Sigaud via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Can compiler switches be used with the shebang notation? If yes, there
is certainly a GDC flag (-run?) that tells it to run the generated
executable.
it's possible to use
What changed? It ran okay with early beta versions, but not
with the release.
Paul
It compiles in beta-5 but not beta-6. Is the list of changes in
the beta testing wiki complete? None seem pertinent.
monarch_dodra: Thanks for checking. I was trying to avoid tearing
everything down. I
Hi All,
I am playing with a small hack OS for fun and in 2066 there are
these undefined refs (I have no druntime):
_d_arraybounds (new to 2066)
_d_assert (new to 2066)
_d_unittest (new to 2066)
_Dmodule_ref (also in 2065)
_d_dso_registry (also in 2065)
It is trivial to stub these out but it
I'm trying to compile the onDispatch demo program from The D
Programming Language (page 387). At first I had an import
problem, but I fixed that. Now, however, when I try to call
a.do_something_cool, I get an error message saying:
onDispatch.d(43): Error: no property 'do_something_cool' for
45 matches
Mail list logo