Hello,
I am quite new to D and working my way through the D tutorials.
While learning about slices and capacity I found that depending
upon the initial number of elements in a slice (and hence its
capacity) the behavior of the code changes. Consider this program:
snip
import std.stdio;
On 05/29/2014 12:37 AM, Sourav wrote:
the behavior totally depends upon how many
elements were present initially in the array, which means, the capacity
of a slice can actually introduces little surprises in the code! Is this
expected behavior or am I entirely missing something here?
It is
Thanks! Just what I needed to understand. :-)
On Thursday, 29 May 2014 at 08:12:10 UTC, Ali Çehreli wrote:
On 05/29/2014 12:37 AM, Sourav wrote:
the behavior totally depends upon how many
elements were present initially in the array, which means,
the capacity
of a slice can actually
On Wednesday, 28 May 2014 at 17:33:19 UTC, monarch_dodra wrote:
On Wednesday, 28 May 2014 at 14:36:25 UTC, Chris wrote:
I use Appender to fill an array. The Appender is a class
variable and is not instantiated with each function call to
save instantiation. However, the return value or the
On Thursday, 29 May 2014 at 08:49:10 UTC, Chris wrote:
monarch_dodra:
Hm. This last point might be an issue. If I process a large
input (text in this case) then I might run into trouble with
append as a class variable. I also had a weird bug, because I
didn't clear the memory for overwrite.
On Thursday, 29 May 2014 at 12:04:35 UTC, monarch_dodra wrote:
On Thursday, 29 May 2014 at 08:49:10 UTC, Chris wrote:
monarch_dodra:
Hm. This last point might be an issue. If I process a large
input (text in this case) then I might run into trouble with
append as a class variable. I also had
//*** CODE **
mixin(version = foo;);
version(foo)
{
void main(){}
}
//** END CODE ***
If it's illegal in D, what is the reason where is documented?
The reason I was considering such a construct is the following:
Some C libraries have an associated config.h header that
On Thu, 29 May 2014 10:45:28 -0400, safety0ff safety0ff@gmail.com
wrote:
//*** CODE **
mixin(version = foo;);
version(foo)
{
void main(){}
}
//** END CODE ***
If it's illegal in D, what is the reason where is documented?
The reason I was considering such a
On Thursday, 29 May 2014 at 15:02:48 UTC, Steven Schveighoffer
wrote:
Even if that is valid code, you are much better off using enums
and static if.
enum includeSomeFeature = ...
static if(includeSomeFeature)
{
...
}
These work much more like #defines, and can be seen outside the
module.
Vance Miller Kitchens really do represent excellent value for
money. No wonder Big kitchen stores hate Vance Miller Kitchens so
much.
I know that we can use MSVC to build a 64 bit program, but is it
also possible to use it to build a 32 bit program as well?
On Thursday, 29 May 2014 at 18:25:19 UTC, Jeremy DeHaan wrote:
I know that we can use MSVC to build a 64 bit program, but is
it also possible to use it to build a 32 bit program as well?
Yes of course it is possible.
It you are talking about Visual-D then it is possible there too.
Is there a way to read a text file into a sting at compile time
in D2 ?
It would be great to read for example some JSON file and then
parse it using CTFU and create some D code based on it.
string a = import(file.txt);
dmd yourprogram.d -Jlocation_of_file
so for example
dmd yourprogram.d -J.
if file.txt is in the same directory as the .d file.
On Thursday, 29 May 2014 at 20:21:32 UTC, Adam D. Ruppe wrote:
string a = import(file.txt);
dmd yourprogram.d -Jlocation_of_file
so for example
dmd yourprogram.d -J.
if file.txt is in the same directory as the .d file.
Excellent, thank you Adam!
Now another question is it also possible
Remo:
is it also possible to save/write string at compile time?
There is pragma(msg, ...) but it's a little crappy. There are
plans and a pull request for a good _ctWrite, but it's stalled
for reasons unknown to me.
Bye,
bearophile
On Thursday, 29 May 2014 at 20:38:30 UTC, Remo wrote:
Now another question is it also possible to save/write string
at compile time?
Sort of, use
pragma(msg, some string);
and it will be printed out when that code is compiled. Important
that it is when the code is compiled, NOT when the
On Thursday, 29 May 2014 at 20:44:09 UTC, bearophile wrote:
Remo:
is it also possible to save/write string at compile time?
There is pragma(msg, ...) but it's a little crappy. There are
plans and a pull request for a good _ctWrite, but it's stalled
for reasons unknown to me.
Bye,
On Thu, 29 May 2014 20:12:52 +
Remo via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:
On Thursday, 29 May 2014 at 18:25:19 UTC, Jeremy DeHaan wrote:
I know that we can use MSVC to build a 64 bit program, but is
it also possible to use it to build a 32 bit program as well?
I'd like to get a list of all classes in the current module, so I
came up with this code:
class Test {}
class TestChild: Test {}
class TestChildChild: TestChild {}
void main()
{
foreach (item; __traits(allMembers, mixin(__MODULE__)))
{
static if
class Test {}
class TestChild: Test {}
class TestChildChild: TestChild {}
alias Alias(alias Symbol) = Symbol; // this does the trick
void main()
{
foreach (item; __traits(allMembers, mixin(__MODULE__)))
{
alias sym = Alias!(__traits(getMember, mixin(__MODULE__),
item));
On Thursday, 29 May 2014 at 23:18:32 UTC, Dicebot wrote:
class Test {}
class TestChild: Test {}
class TestChildChild: TestChild {}
alias Alias(alias Symbol) = Symbol; // this does the trick
void main()
{
foreach (item; __traits(allMembers, mixin(__MODULE__)))
{
alias sym =
Hi, in C++ I can use smart pointers to wrap raw pointers with
custom deleter to automatically manage C resources. Is there
anything like this in D?
23 matches
Mail list logo