Confusion over delegates seems to be a somewhat common topic,
judging from
http://forum.dlang.org/thread/jbkahhlvevgectisd...@forum.dlang.org
and
http://stackoverflow.com/questions/6431884/function-and-delegate-literals-in-d.
I'm also somewhat confused by functions vs. function literals and
h
I'm having trouble understanding the difference between casting
and std.conv.to. Any help?
On Wednesday, July 03, 2013 15:37:28 captaindet wrote:
> hi,
>
> whilst converting some of my C code into D i got stuck.
>
> in C:
>
> typedef struct { /* info */ } INFO;
> INFO info;
> size_t checkio;
> // read INFO from data file:
> pf_datafile = fopen("datafile","rb");
> checkio = fread((char
On 07/03/2013 01:37 PM, captaindet wrote:
> in C:
>
> typedef struct { /* info */ } INFO;
> INFO info;
> size_t checkio;
> // read INFO from data file:
> pf_datafile = fopen("datafile","rb");
> checkio = fread((char *) &info, sizeof(info), 1, pf_datafile);
Just a reminder: The operation above is
On Wednesday, 3 July 2013 at 20:37:24 UTC, captaindet wrote:
hi,
whilst converting some of my C code into D i got stuck.
in C:
typedef struct { /* info */ } INFO;
INFO info;
size_t checkio;
// read INFO from data file:
pf_datafile = fopen("datafile","rb");
checkio = fread((char *) &info, sizeo
I'd like to have a function:
string mangle(string mangled_string);
unittest{
void foo(int x){}
assert(foo.mangleof.demangle.mangle == foo.mangleof);
}
is there such a functionality, even partially?
inout(int) foo (inout int a)
{
writeln(a);
return a;
}
I don't know if this is the official method, but
writeln(cast(const)x);
works.
Trying to get answers at:
http://stackoverflow.com/questions/17460065/how-to-print-inout-parameters
How do you open stdout in binary mode with D/Phobos?
In C++ you use something like:
setmode(fileno(stdout), O_BINARY);
(I don't even know where to find O_BINARY in core.stdc).
Bye and thank you,
bearophile
On 7/3/13 12:52 PM, Artur Skawina wrote:
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b){ writeln("overload long"); }
auto pickOverload(alias FP, A...)() @property { typeof(FP(A.init)) function(A)
fp = &FP; return fp;}
void main()
{
a
On 07/03/13 22:44, H. S. Teoh wrote:
> On Wed, Jul 03, 2013 at 10:10:08PM +0200, Artur Skawina wrote:
>> On 07/03/13 21:02, H. S. Teoh wrote:
>>> On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote:
void main()
{
auto b = pickOverload!(foo, long);
>>>
>>> Now *
On Wed, Jul 03, 2013 at 10:10:08PM +0200, Artur Skawina wrote:
> On 07/03/13 21:02, H. S. Teoh wrote:
> > On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote:
> >>void main()
> >>{
> >>auto b = pickOverload!(foo, long);
> >
> > Now *that's* what I call coolness. Self-docu
hi,
whilst converting some of my C code into D i got stuck.
in C:
typedef struct { /* info */ } INFO;
INFO info;
size_t checkio;
// read INFO from data file:
pf_datafile = fopen("datafile","rb");
checkio = fread((char *) &info, sizeof(info), 1, pf_datafile);
how do i do this in D? i'd like to
On 07/03/13 21:02, H. S. Teoh wrote:
> On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote:
>>void main()
>>{
>>auto b = pickOverload!(foo, long);
>
> Now *that's* what I call coolness. Self-documenting and convenient to
> use (though in this case it's arguable whether it
On 07/03/13 19:10, Brad Anderson wrote:
> On Wednesday, 3 July 2013 at 16:35:18 UTC, Artur Skawina wrote:
>> On 07/03/13 18:29, Brad Anderson wrote:
>>> On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote:
On 07/03/13 02:22, Brad Anderson wrote:
> C++11's std::tuple includes a f
On Saturday, 29 June 2013 at 19:44:00 UTC, Peter Neubauer wrote:
Please explain why this error happens in the following code:
import std.algorithm;
struct S
{
void foo ()
{
int f1 (int a) { return conv(a); }
int delegate (int) f2 = &conv;
int[] x = [1, 2, 3];
x.map!conv;
On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote:
> On 07/03/13 18:24, H. S. Teoh wrote:
> > On Wed, Jul 03, 2013 at 06:07:07PM +0200, Artur Skawina wrote:
> >> The context dependence isn't ideal, but what's the alternative?...
> > [...]
> >
> > Explicit syntax for specifying overload
On Wed, Jul 03, 2013 at 07:56:28PM +0200, Marco Leise wrote:
> Am Tue, 2 Jul 2013 22:21:52 -0700
> schrieb "H. S. Teoh" :
>
> > On Tue, Jul 02, 2013 at 10:14:33PM -0700, Ali Çehreli wrote:
> > [...]
> > > import std.stdio;
> > > import std.conv;
> > >
> > > void main()
> > > {
> > > auto a =
On 2013-07-03, 02:22, Brad Anderson wrote:
C++11's std::tuple includes a function std::tie that takes references to
the arguments and returns a tuple that maintains the references to the
arguments.
Along with the usual cases where you'd want reference semantics it also
enables this intere
Am Tue, 2 Jul 2013 22:21:52 -0700
schrieb "H. S. Teoh" :
> On Tue, Jul 02, 2013 at 10:14:33PM -0700, Ali Çehreli wrote:
> [...]
> > import std.stdio;
> > import std.conv;
> >
> > void main()
> > {
> > auto a = to!double("151.42499");
> > writefln("%.60f", a);
> > }
>
> I wouldn't write i
You have to parse the unnamed import files, list all their
identifiers (global variables, public functions etc.) and search
for them. ;)
That could be a bit complicated. ;) Therefore I don't want to do
it. Even with named imports you can get false positives.
But if you like it, you could impro
Am Sat, 22 Jun 2013 23:27:00 +0200
schrieb "bearophile" :
> Ali Çehreli:
>
> > The code compiles under 32-bit (e.g. with the -m32 compiler
> > switch) where size_t is an alias of uint.
>
> Oh, I see. I compile most of the code on a 32 bit system.
>
> I asked Walter to warn d programmers agains
On Wednesday, 3 July 2013 at 16:35:18 UTC, Artur Skawina wrote:
On 07/03/13 18:29, Brad Anderson wrote:
On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote:
On 07/03/13 02:22, Brad Anderson wrote:
C++11's std::tuple includes a function std::tie that takes
references to the arguments
On 07/03/13 18:24, H. S. Teoh wrote:
> On Wed, Jul 03, 2013 at 06:07:07PM +0200, Artur Skawina wrote:
>> The context dependence isn't ideal, but what's the alternative?...
> [...]
>
> Explicit syntax for specifying overloads? ;-) Not like that would happen
> in D, though.
Real Programmers need no
On 07/03/13 18:29, Brad Anderson wrote:
> On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote:
>> On 07/03/13 02:22, Brad Anderson wrote:
>>> C++11's std::tuple includes a function std::tie that takes references to
>>> the arguments and returns a tuple that maintains the references to t
On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote:
On 07/03/13 02:22, Brad Anderson wrote:
C++11's std::tuple includes a function std::tie that takes
references to the arguments and returns a tuple that maintains
the references to the arguments.
Along with the usual cases where y
On Wed, Jul 03, 2013 at 06:07:07PM +0200, Artur Skawina wrote:
> On 07/03/13 17:43, H. S. Teoh wrote:
> > On Wed, Jul 03, 2013 at 05:41:25PM +0200, Artur Skawina wrote:
> >> On 07/03/13 17:27, H. S. Teoh wrote:
> >>> On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote:
> On Wednesday,
On 07/03/13 17:43, H. S. Teoh wrote:
> On Wed, Jul 03, 2013 at 05:41:25PM +0200, Artur Skawina wrote:
>> On 07/03/13 17:27, H. S. Teoh wrote:
>>> On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote:
On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote:
> On 07/03/13 16:52
On Wed, Jul 03, 2013 at 05:41:25PM +0200, Artur Skawina wrote:
> On 07/03/13 17:27, H. S. Teoh wrote:
> > On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote:
> >> On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote:
> >>> On 07/03/13 16:52, John Colvin wrote:
> Is there any
On 07/03/13 17:27, H. S. Teoh wrote:
> On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote:
>> On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote:
>>> On 07/03/13 16:52, John Colvin wrote:
Is there any way to take the address of any of an overloaded set
of functions?
>
On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote:
> On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote:
> >On 07/03/13 16:52, John Colvin wrote:
> >>Is there any way to take the address of any of an overloaded set
> >>of functions?
> >>
> >>import std.stdio;
> >>
> >>void foo
On 07/03/13 17:17, John Colvin wrote:
> On Wednesday, 3 July 2013 at 15:05:00 UTC, Dicebot wrote:
>> On Wednesday, 3 July 2013 at 14:52:32 UTC, John Colvin wrote:
>>> Is there any way to take the address of any of an overloaded set of
>>> functions?
>>>
>>> import std.stdio;
>>>
>>> void foo(int a
On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote:
On 07/03/13 16:52, John Colvin wrote:
Is there any way to take the address of any of an overloaded
set of functions?
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b){ writeln("overload long"); }
voi
On Wednesday, 3 July 2013 at 15:05:00 UTC, Dicebot wrote:
On Wednesday, 3 July 2013 at 14:52:32 UTC, John Colvin wrote:
Is there any way to take the address of any of an overloaded
set of functions?
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b){ writeln("overl
On Wednesday, 3 July 2013 at 14:52:32 UTC, John Colvin wrote:
Is there any way to take the address of any of an overloaded
set of functions?
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b){ writeln("overload long"); }
void main()
{
auto b = &foo; //ambiguous
On 07/03/13 17:03, Artur Skawina wrote:
> On 07/03/13 16:52, John Colvin wrote:
>> Is there any way to take the address of any of an overloaded set of
>> functions?
>>
>> import std.stdio;
>>
>> void foo(int a){ writeln("overload int"); }
>> void foo(long b){ writeln("overload long"); }
>>
>> void
On 07/03/13 16:52, John Colvin wrote:
> Is there any way to take the address of any of an overloaded set of functions?
>
> import std.stdio;
>
> void foo(int a){ writeln("overload int"); }
> void foo(long b){ writeln("overload long"); }
>
> void main()
> {
> auto b = &foo; //ambiguous => err
Is there any way to take the address of any of an overloaded set
of functions?
import std.stdio;
void foo(int a){ writeln("overload int"); }
void foo(long b){ writeln("overload long"); }
void main()
{
auto b = &foo; //ambiguous => error
b(2); //valid for either overload
}
On Wednesday, 3 July 2013 at 08:23:40 UTC, monarch_dodra wrote:
On Wednesday, 3 July 2013 at 06:18:28 UTC, Jonathan M Davis
wrote:
On Wednesday, July 03, 2013 08:11:50 Josh wrote:
Long story short, I think both would be a great addition to
phobos/D. I'd personally really want to play with dec
On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote:
Well, aliases can be used to get a similar effect.
template tie(A...) { alias tie = A; }
tie!(a, b) = tuple(1, 2);
artur
Which is actually already in Phobos:
TypeTuple!(a, b) = tuple(1, 2);
On 07/03/13 02:22, Brad Anderson wrote:
> C++11's std::tuple includes a function std::tie that takes references to the
> arguments and returns a tuple that maintains the references to the arguments.
>
> Along with the usual cases where you'd want reference semantics it also
> enables this intere
Josh:
Is there any way I would be able to hold that number then?
One way to do that is with a simple rationals library,
represented as pairs of bigints.
Bye,
bearophile
On Wednesday, 3 July 2013 at 08:27:52 UTC, Maxim Fomin wrote:
On Wednesday, 3 July 2013 at 08:23:40 UTC, monarch_dodra wrote:
My brother in law writes financial apps, and in that field,
using floating points type is *legally* forbidden.
Really? What kind of apps?
I meant "apps" as in sho
On Wednesday, 3 July 2013 at 06:12:46 UTC, Namespace wrote:
On Tuesday, 2 July 2013 at 21:49:37 UTC, Gabi wrote:
Hi,
How to find unused imports ?
It seems the compiler doesn't do it, but is there any other
tool for that?
This seems like small issue, but those unused imports pile up
pretty qu
On Wednesday, 3 July 2013 at 08:23:40 UTC, monarch_dodra wrote:
My brother in law writes financial apps, and in that field,
using floating points type is *legally* forbidden.
Really? What kind of apps?
On Wednesday, 3 July 2013 at 06:18:28 UTC, Jonathan M Davis wrote:
On Wednesday, July 03, 2013 08:11:50 Josh wrote:
Jonathan, do you know of any fixed point D library? If not,
would
it be worth me making one for phobos?
I am unaware of one, and I don't really know why anyone would
really wan
45 matches
Mail list logo