Functions, intrinsics, flexibility

bearophile bearophileHUGS at lycos.com
Sun Sep 18 11:57:40 PDT 2011


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


More information about the Digitalmars-d-learn mailing list