digitalmars.D.learn - Functions, intrinsics, flexibility
- bearophile (17/17) Sep 18 2011 I don't know what is the right design in this case. Intrinsics are usefu...
- Timon Gehr (4/21) Sep 18 2011 +1, the compiler should just rewrite your example so that it 'just
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (4/38) Sep 19 2011 You could write a wrapper function that calls the intrinsic, but I
- Ary Manzana (2/41) Sep 19 2011 Or maybe you could define a wrapper function that calls the intrinsic...
I don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy because they allow more flexibility, like taking their address ("first class functions"): import std.math; void main() { auto a = [&sin, &cos]; } DMD 2.055: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D3std4math3sinFNaNbNfeZe test.obj(test) Error 42: Symbol Undefined _D3std4math3cosFNaNbNfeZe Isn't it possible to find some middle way that allows me to use std.math.sin as true functions, while keeping the advantages of intrinsics? (Currently I define wrapper functions like mysin, mycos, etc). Bye, bearophile
Sep 18 2011
On 09/18/2011 08:57 PM, bearophile wrote:I don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy because they allow more flexibility, like taking their address ("first class functions"): import std.math; void main() { auto a = [&sin,&cos]; } DMD 2.055: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D3std4math3sinFNaNbNfeZe test.obj(test) Error 42: Symbol Undefined _D3std4math3cosFNaNbNfeZe Isn't it possible to find some middle way that allows me to use std.math.sin as true functions, while keeping the advantages of intrinsics? (Currently I define wrapper functions like mysin, mycos, etc). Bye, bearophile+1, the compiler should just rewrite your example so that it 'just works'. An alternative to your fix is to create an object file that contains the appropriate symbols.
Sep 18 2011
On 18-09-2011 21:47, Timon Gehr wrote:On 09/18/2011 08:57 PM, bearophile wrote:You could write a wrapper function that calls the intrinsic, but I suppose this defeats the purpose... - AlexI don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy because they allow more flexibility, like taking their address ("first class functions"): import std.math; void main() { auto a = [&sin,&cos]; } DMD 2.055: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D3std4math3sinFNaNbNfeZe test.obj(test) Error 42: Symbol Undefined _D3std4math3cosFNaNbNfeZe Isn't it possible to find some middle way that allows me to use std.math.sin as true functions, while keeping the advantages of intrinsics? (Currently I define wrapper functions like mysin, mycos, etc). Bye, bearophile+1, the compiler should just rewrite your example so that it 'just works'. An alternative to your fix is to create an object file that contains the appropriate symbols.
Sep 19 2011
On 9/19/11 3:32 PM, Alex Rønne Petersen wrote:On 18-09-2011 21:47, Timon Gehr wrote:Or maybe you could define a wrapper function that calls the intrinsic...On 09/18/2011 08:57 PM, bearophile wrote:You could write a wrapper function that calls the intrinsic, but I suppose this defeats the purpose... - AlexI don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy because they allow more flexibility, like taking their address ("first class functions"): import std.math; void main() { auto a = [&sin,&cos]; } DMD 2.055: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D3std4math3sinFNaNbNfeZe test.obj(test) Error 42: Symbol Undefined _D3std4math3cosFNaNbNfeZe Isn't it possible to find some middle way that allows me to use std.math.sin as true functions, while keeping the advantages of intrinsics? (Currently I define wrapper functions like mysin, mycos, etc). Bye, bearophile+1, the compiler should just rewrite your example so that it 'just works'. An alternative to your fix is to create an object file that contains the appropriate symbols.
Sep 19 2011