www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - loadLibrary string

reply =?UTF-8?B?Ikx1w61z?= Marques" <luismarques gmail.com> writes:
In the talk "Shared Libraries in D by Martin Nowak" loadLibrary 
is presented with the signature:

     void* loadLibrary(string path);

But in the docs we have:

     static void* loadLibrary(in char[] name);

Any particular reason for using "in char[]" instead of string? (I 
suppose the "in" makes the string head constant, but not the 
string body.)

Path also seems slightly more explicit than "name", so consider 
that if someone wants to change it.
Jun 01 2013
next sibling parent "David Nadlinger" <see klickverbot.at> writes:
On Saturday, 1 June 2013 at 20:01:18 UTC, Luís Marques wrote:
 Any particular reason for using "in char[]" instead of string? 
 (I suppose the "in" makes the string head constant, but not the 
 string body.)

There is no head const in D. — David
Jun 01 2013
prev sibling next sibling parent =?UTF-8?B?Ikx1w61z?= Marques" <luismarques gmail.com> writes:
Either Google is buggy or there may be something wrong with the 
times presented by the forum. I was searching for loadLibrary and 
found my own post:

     loadLibrary string - D Programming Language Discussion
     forum.dlang.org/post/xtkqpnortzookwvryzlv forum.dlang.org‎
     13 hours ago - 1 post

This wasn't 13 hours ago. Is there some timestamp that may be 
lacking the correct timezone information, or something like that, 
that could help Google correctly deduce the time?
Jun 01 2013
prev sibling next sibling parent =?UTF-8?B?Ikx1w61z?= Marques" <luismarques gmail.com> writes:
On Saturday, 1 June 2013 at 20:20:14 UTC, David Nadlinger wrote:
 There is no head const in D.

So is having an "in char[]" the same as having an immutable(char)[] / string?
Jun 01 2013
prev sibling next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Saturday, 1 June 2013 at 20:23:23 UTC, Luís Marques wrote:
 So is having an "in char[]" the same as having an 
 immutable(char)[] / string?

Almost. in basically means const, so it can take strings or char[]. void foo(string s); void foo2(in char s); char[] a; string b; foo(a); // not allowed foo(b); // allowed foo2(a); // allowed foo2(b); // also allowed
Jun 01 2013
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Saturday, June 01, 2013 22:23:22 =?UTF-8?B?Ikx1w61z?=.Marques 
<luismarques gmail.com> puremagic.com wrote:
 On Saturday, 1 June 2013 at 20:20:14 UTC, David Nadlinger wrote:
 There is no head const in D.

So is having an "in char[]" the same as having an immutable(char)[] / string?

"in char" is equivalent to "scope const char[]". The scope does not currently have any effect, but by having const char[], char[], const(char)[], and immutable(char)[] can all be passed to the loadLibrary, whereas if it accepted string, then only immutable(char)[] could be passed to it. - Jonathan M Davis
Jun 01 2013