The sense of pure functions isn't clear to me.
What is the advantage of pure functions / methods?
I inform the compiler with const that this method does not
change the current object, and therefore he can optimize (at
least in C++) this method. How and what optimized the compiler if
i have
On 4/20/12 4:06 PM, Namespace wrote:
The sense of pure functions isn't clear to me.
What is the advantage of pure functions / methods?
I inform the compiler with const that this method does not change the
current object, and therefore he can optimize (at least in C++) this
method. How and what
On 4/20/2012 3:06 AM, Namespace wrote:
The sense of pure functions isn't clear to me.
What is the advantage of pure functions / methods?
I inform the compiler with const that this method does not change the
current object, and therefore he can optimize (at least in C++) this
method. How and what
Jakob Ovrum , dans le message (digitalmars.D.learn:34948), a écrit :
On Thursday, 19 April 2012 at 18:34:41 UTC, Jacob Carlborg wrote:
Named arguments would probably be better for this.
fun(c = 5);
Maybe so, but `fun(c = 5);` is not an additive change, while the
OP's suggestion actually
On 04/20/2012 10:06 AM, Namespace wrote:
The sense of pure functions isn't clear to me.
What is the advantage of pure functions / methods?
1. It enables stateless reasoning about program parts.
2. It enables certain compiler optimizations.
I inform the compiler with const that this method
On Friday, 20 April 2012 at 09:55:28 UTC, Timon Gehr wrote:
On 04/20/2012 10:06 AM, Namespace wrote:
The sense of pure functions isn't clear to me.
What is the advantage of pure functions / methods?
1. It enables stateless reasoning about program parts.
2. It enables certain compiler
On 2012-04-20 11:17, Christophe wrote:
Jakob Ovrum , dans le message (digitalmars.D.learn:34948), a écrit :
On Thursday, 19 April 2012 at 18:34:41 UTC, Jacob Carlborg wrote:
Named arguments would probably be better for this.
fun(c = 5);
Maybe so, but `fun(c = 5);` is not an additive
Namespace:
So only GDC optimized pure functions at all?
I've seen DMD performs some optimizations with strongly pure
functions that return integral values.
If you have code like:
int sqr(in int x) pure nothrow { return x * x; }
int y = ...
auto r = sqr(y) + sqr(y);
I think DMD replaces
On Friday, 20 April 2012 at 09:17:18 UTC,
trav...@phare.normalesup.org (Christophe) wrote:
Jakob Ovrum , dans le message (digitalmars.D.learn:34948), a
écrit :
On Thursday, 19 April 2012 at 18:34:41 UTC, Jacob Carlborg
wrote:
Named arguments would probably be better for this.
fun(c = 5);
On Friday, 20 April 2012 at 11:09:30 UTC, Jacob Carlborg wrote:
On 2012-04-20 11:17, Christophe wrote:
Jakob Ovrum , dans le message (digitalmars.D.learn:34948), a
écrit :
On Thursday, 19 April 2012 at 18:34:41 UTC, Jacob Carlborg
wrote:
Named arguments would probably be better for this.
Am 20.04.2012 00:34, schrieb Stephen Jones:
In the same vein, I have getting nothing on the screen when there should
be rendered a red triangle. The vertex positions are those used by
McKeeson http://www.arcsynthesis.org/gltut/, being in ndc fall within
the frustum. The code for setting up vao
Hi,
I am migrating a C++ project to D and I have hit a roadblock that I hope
you might help me with.
My code is heavily inspired by the COM architecture, so I have naturally
take a look at std/c/windows/com.d, just to find out that it does not
contain all I need.
In the C++ code I have several
ixid:
fun( , 4, ); //Modifies b
fun( , , 5); //Modifies c
for when you want to call fun with other fields not being
default? This would seem more flexible and pretty clear what is
intended.
I think that for the programmer's eye it's easy to miss one or
more of those commas, when reading
On Thursday, 19 April 2012 at 20:59:05 UTC, Jonathan M Davis
wrote:
On Thursday, April 19, 2012 21:14:43 Xan wrote:
Hi, I read http://dlang.org/operatoroverloading.html but in my
code it does not work. I tried to overload '*' binary operator
in
my class Algorisme:
[...]
class Algorisme(U,V)
On 04/20/2012 03:23 PM, Martin Drasar wrote:
Hi,
I am migrating a C++ project to D and I have hit a roadblock that I hope
you might help me with.
My code is heavily inspired by the COM architecture, so I have naturally
take a look at std/c/windows/com.d, just to find out that it does not
What fails if I want to define this:
Algorisme!(T,V) opBinary(string op)(Algorisme!(T,U) alg) {
if (op==*) {
//fer la funció composicio
return new Algorisme!(T,V)(Composició de ~this.nom ~ i
~ alg.nom, 1, function(T t) { return
On 20.04.2012 18:10, Xan wrote:
What fails if I want to define this:
Algorisme!(T,V) opBinary(string op)(Algorisme!(T,U) alg) {
Algorisme!(T,V) opBinary(string op, T)(Algorisme!(T,U) alg) {
You need to name what T is and that is *sometype*. Anyway I suggest
getting a decent book (TDPL).
On Friday, 20 April 2012 at 14:10:31 UTC, Xan wrote:
What fails if I want to define this:
Algorisme!(T,V) opBinary(string op)(Algorisme!(T,U) alg) {
if (op==*) {
//fer la funció composicio
return new Algorisme!(T,V)(Composició de ~this.nom ~ i
On 20.4.2012 16:09, Timon Gehr wrote:
Thanks Timon for the answer.
My questions are following:
- can mixin templates be used this way?
They can only mixin declarations.
- why are they complaining?
Because if is a statement and not a declaration.
Ok.
- is there a better way to do
On Friday, 20 April 2012 at 14:18:37 UTC, Dmitry Olshansky wrote:
On 20.04.2012 18:10, Xan wrote:
What fails if I want to define this:
Algorisme!(T,V) opBinary(string op)(Algorisme!(T,U) alg) {
Algorisme!(T,V) opBinary(string op, T)(Algorisme!(T,U) alg) {
You need to name what T is and
Hello,
I want to overload a primitive type operator so that I can do
something like
double a;
myStruct b;
writeln(a + b);
but have no idea how to do it. Something similar(?) is already
implemented in the language, i.e.
double x;
double[] y;
writeln(x + y);
but after searching the
Dominic Jones:
I want to overload a primitive type operator so that I can do
something like
double a;
myStruct b;
writeln(a + b);
You can't overload the operator of a primitive, but binary
operators come in left and right versions:
http://dlang.org/operatoroverloading.html#Binary
On Friday, 20 April 2012 at 14:57:03 UTC, Martin Drasar wrote:
On 20.4.2012 16:09, Timon Gehr wrote:
I tried but it still refuses to compile:
string interfaceGuid(string ifaceName)
{
return ifaceName ~ Guid;
}
mixin template EXPOSE_INTERFACES(T...)(T args)
Try this:
mixin template
Am 20.04.2012 18:41, schrieb bearophile:
Dominic Jones:
I want to overload a primitive type operator so that I can do
something like
double a;
myStruct b;
writeln(a + b);
You can't overload the operator of a primitive, but binary operators
come in left and right versions:
...
Bye,
On Friday, April 20, 2012 15:37:57 Xan wrote:
Thanks, Jonathan. I suppose with 'if' (dynamic), it generates
Exception if we call with other operator than '*', isn't?
Exception? No. You get a compilation error. You should read
http://dlang.org/template.html#Constraint
On Fri, Apr 20, 2012 at 07:12:41PM +0200, Mafi wrote:
Am 20.04.2012 18:41, schrieb bearophile:
Dominic Jones:
I want to overload a primitive type operator so that I can do
something like
double a;
myStruct b;
writeln(a + b);
You can't overload the operator of a primitive, but binary
On 20.04.2012 19:14, Xan wrote:
On Friday, 20 April 2012 at 14:18:37 UTC, Dmitry Olshansky wrote:
On 20.04.2012 18:10, Xan wrote:
What fails if I want to define this:
Algorisme!(T,V) opBinary(string op)(Algorisme!(T,U) alg) {
Algorisme!(T,V) opBinary(string op, T)(Algorisme!(T,U) alg) {
Yes, you're wright. So in.
But what fails?
I reveice these errors and I have no idea what fails!
Sorry, the errors are:
$ gdmd-4.6 algorisme.d
algorisme.d:35: Error: 'this' is only defined in non-static
member functions, not __funcliteral1
algorisme.d:35: Error: function
On Friday, 20 April 2012 at 18:47:14 UTC, Dmitry Olshansky wrote:
On 20.04.2012 19:14, Xan wrote:
On Friday, 20 April 2012 at 14:18:37 UTC, Dmitry Olshansky
wrote:
On 20.04.2012 18:10, Xan wrote:
What fails if I want to define this:
Algorisme!(T,V) opBinary(string op)(Algorisme!(T,U) alg) {
On 20.04.2012 23:33, Xan wrote:
Yes, you're wright. So in.
But what fails?
I reveice these errors and I have no idea what fails!
Sorry, the errors are:
$ gdmd-4.6 algorisme.d
algorisme.d:35: Error: 'this' is only defined in non-static member
functions, not __funcliteral1
Easy - _this_
Is there a way to format std.datetime.Date objects with a custom format
string? In particular, I'd like to reuse month short names defined in
std.datetime, but it appears that the names are private. I'd really
rather not duplicate them by hand, if there's a way to get them.
Alternatively, if
On Friday, April 20, 2012 13:29:34 H. S. Teoh wrote:
Is there a way to format std.datetime.Date objects with a custom format
string? In particular, I'd like to reuse month short names defined in
std.datetime, but it appears that the names are private. I'd really
rather not duplicate them by
David suggested I start a new thread rather than asking on an old
existing one (probably wants to get rid of me). So what I have
done is created the most parred back, hello world type program
that could run under the GL3 enforcement policies dictated by
Derelict2. Fixed function pipeline is
33 matches
Mail list logo