Re: Can D interface with Free Pascal?

2016-01-28 Thread bearophile via Digitalmars-d-learn
FreeSlave: On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote: Not directly. You can declare cdecl function on Free Pascal side and call it as extern(C). What about extern(Pascal)? https://dlang.org/spec/attribute.html#linkage Bye, bearophile

Re: How to represent struct with trailing array member

2016-01-21 Thread bearophile via Digitalmars-d-learn
ki/Sokoban#Faster_Version You can also add a constructor to such struct, for safety and disallow default construction. Bye, bearophile

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread bearophile via Digitalmars-d-learn
Yazan D: On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote: ubyte[] b = (cast(ubyte*) &a)[0 .. int.sizeof]; Better to use the actual size: ubyte[] b = (cast(ubyte*) &a)[0 .. a.sizeof]; Bye, bearophile

Re: conver BigInt to string

2015-11-05 Thread bearophile via Digitalmars-d-learn
void main() { import std.stdio, std.algorithm, std.conv, std.bigint, std.string; auto n = 17.BigInt ^^ 179; n.text.dup.representation.sort().release.assumeUTF.writeln; } Better: n.to!(char[]).representation.sort().release.assumeUTF.writeln; Bye, bearophile

Re: conver BigInt to string

2015-11-05 Thread bearophile via Digitalmars-d-learn
Namal: Hello I am trying to convert BigInt to string like that while trying to sort it: void main() { import std.stdio, std.algorithm, std.conv, std.bigint, std.string; auto n = 17.BigInt ^^ 179; n.text.dup.representation.sort().release.assumeUTF.writeln; } Bye, bearophile

Re: array function

2015-08-31 Thread bearophile via Digitalmars-d-learn
Namal: std::vector foo(int N){ std::vector V(N); int some_array[N]; VLAs are not present in D. Bye, bearophile

[Rosettacode] sum of powers conjecture

2015-07-26 Thread bearophile via Digitalmars-d-learn
of_powers_conjecture#Third_version Bye, bearophile

Re: Ada to D - an array for storing values of each of the six bits which are sufficient

2015-05-01 Thread bearophile via Digitalmars-d-learn
without SIMD, perhaps about as nice as the Ada ones (D sometimes offers good enough tools to build what you need). Posible use: PackedDynamicArray!6 pa; // On heap. PackedFixedArray!(6, 300) pfa; // On stack. Bye, bearophile

Re: Implicit conversion error

2015-04-30 Thread bearophile via Digitalmars-d-learn
uot; is always a 32 bit signed integer. D allows implicit assignment of a 32 bit size_t to int but not a 64 bit size_t to an int. I agree that it's a bit of a mess. Bye, bearophile

Re: Ada to D - an array for storing values of each of the six bits which are sufficient

2015-04-30 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: There is an array of values to store each of which sufficiently 6 bits. As it is written down on the D? You can't do it directly in D. Someone has to write a packed array data structure to do it. Bye, bearophile

Re: Possible to write a classic fizzbuzz example using a UFCS chain?

2015-04-28 Thread bearophile via Digitalmars-d-learn
edSwitch( 0, "FizzBuzz", 3, "Fizz", 5, "Buzz", 6, "Fizz", 9, "Fizz", 10, "Buzz", 12, "Fizz", /*else*/ i.text)) .reverseArgs!writefln("%-(%s\n%)"); } Bye, bearophile

Re: __gshared static

2015-04-24 Thread bearophile via Digitalmars-d-learn
Steven Schveighoffer: These are the same, __gshared overrides static. Isn't forbidding "__gshared static" a good idea then, to avoid user confusion? Bye, bearophile

Re: function ref param vs pointer param

2015-04-24 Thread bearophile via Digitalmars-d-learn
too. But this idea was refused for D (also because it goes against UFCS chains). Bye, bearophile

Re: function ref param vs pointer param

2015-04-24 Thread bearophile via Digitalmars-d-learn
need the "&" when you call the function. Bye, bearophile

Re: Structural exhaustive matching

2015-04-21 Thread bearophile via Digitalmars-d-learn
uot;. Or you can use Algebraic from Phobos. Sometimes you can use another Phobos function that simulates an improved switch. Or often you can just give up at using ADTs in D and use what other solutions D offers you (like OOP). Bye, bearophile

Re: multiSort for sorting AA by value

2015-04-21 Thread bearophile via Digitalmars-d-learn
pairs.multiSort!(q{a.value > b.value}, q{a.key < b.key}); assert(pairs[2].key == "beer"); foreach (const ref it; pairs) writeln(it.key, ": ", it.value); } Bye, bearophile

Re: Converting Java code to D

2015-04-20 Thread bearophile via Digitalmars-d-learn
tring label) { this.label = label; } } The constructor doesn't look very useful. Perhaps a named enum is safer. Bye, bearophile

Re: Function name from function pointer

2015-04-11 Thread bearophile via Digitalmars-d-learn
Paul D Anderson: Is there a way to return the name of a function (a string) from a pointer to that function? Perhaps creating a string[void*] AA and initializing with all the function pointers you care about. Bye, bearophile

Re: return the other functions of the void main()

2015-04-09 Thread bearophile via Digitalmars-d-learn
Jack Applegame: writeln(a.find(4).empty ? "No" : "Yes"); canFind? Bye, bearophile

Re: Generating all combinations of length X in an array

2015-04-09 Thread bearophile via Digitalmars-d-learn
wobbles: Have just tested, it is! But with the current D front-end it's not a good idea to generate too many combinations at compile-time. Efficient code doesn't save you from bad usages. Bye, bearophile

Re: function shadowed

2015-04-08 Thread bearophile via Digitalmars-d-learn
ddos: same behavior when overriding methods of base classes This is by design. Bye, bearophile

Re: Generating all combinations of length X in an array

2015-04-08 Thread bearophile via Digitalmars-d-learn
look at the versions here, the usable one is the third: http://rosettacode.org/wiki/Combinations#D Bye, bearophile

Re: Implementing Iterator to support foreach

2015-04-08 Thread bearophile via Digitalmars-d-learn
tcak: I am planning to implement "Iterator" class. But looking at "foreach" statement, it takes a range only. Unless you are just experimenting, it's better to not go against a language and its std lib. Bye, bearophile

Re: Shall I use immutable or const while passing parameters to functions

2015-04-07 Thread bearophile via Digitalmars-d-learn
ave a good reason to do it, and you know what you are doing (and most times you don't know it). More generally, minimize the number of cast() in your D programs. You can use a search to count how many "cast(" there are in your whole D codebase, and you can try to reduce that number. Bye, bearophile

Re: Issue with free() for linked list implementation

2015-04-04 Thread bearophile via Digitalmars-d-learn
code. Here is mine: https://github.com/Dgame/m3/blob/master/source/m3/List.d In 99%+ of cases it's a bad idea to use a linked list. Bye, bearophile

Re: Speed of horizontal flip

2015-04-01 Thread bearophile via Digitalmars-d-learn
necks. You can even replace the *w multiplications with an increment of an index each loop, but this time saving is dwarfed by the reverse(). Bye, bearophile

Re: What ?

2015-03-30 Thread bearophile via Digitalmars-d-learn
Brian Schott: Do this instead: ulong u = 1L << 63; I suggest a more explicit: ulong u = 1UL << 63; Alternative: ulong u = 2UL ^^ 63; Bye, bearophile

Re: Associative Array of Const Objects?

2015-03-29 Thread bearophile via Digitalmars-d-learn
bitwise: I'm a little confused at this point why this doesn't work either: const and immutable are rather different between C++ and D, I suggest you to take a look at the documentation: http://dlang.org/const-faq.html Bye, bearophile

Re: Associative Array of Const Objects?

2015-03-28 Thread bearophile via Digitalmars-d-learn
an associative array of const objects? You meant to say "associative array with const objects as values". I think the short answer is that you can't. This is a breaking change, I think, it broke some of my code too. But perhaps something like Rebindable could be used. Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
se the range formatting of writefln, avoiding the "map", "to", and "join", something like: writefln("%(%d %)", arr); Bye, bearophile

Re: Keep Track of the Best N Nodes in a Graph Traversal Algorithm

2015-03-25 Thread bearophile via Digitalmars-d-learn
Nordlöw: Ahh, a Binary Heap perfectly matches my needs. https://en.wikipedia.org/wiki/Binary_heap http://dlang.org/phobos/std_container_binaryheap.html But isn't topNCopy using a heap? Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
ike we are doing in this thread. Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
[7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1, 2, 2, 8, 5, 8, 8] .sort() .groupBy!((a, b) => a == b) .map!array .array .sort!q{a.length > b.length} .joiner .writeln; } Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
Ali Çehreli: Do you know the story about groupBy? It's a long messy story. Look for it with another name, like chunkBy or something like that. Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
.schwartzSort!(x => tuple(-arr.count!(y => y == x), x)) But calling "count" for each item is not efficient (in both C# and D). If your array is largish, then you need a more efficient solution. Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
8 8 2 2 7 7 0 One solution: void main() { import std.stdio, std.algorithm, std.typecons; auto arr = [7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1, 2, 2, 8, 5, 8, 8]; arr .schwartzSort!(x => tuple(-arr.count!(y => y == x), x)) .writeln; } Bye, bearophile

Re: Keep Track of the Best N Nodes in a Graph Traversal Algorithm

2015-03-25 Thread bearophile via Digitalmars-d-learn
Nordlöw: I have graph traversal algorithm that needs to keep track of the N "best" node visit. std.algorithm.topNCopy? Bye, bearophile

Re: D's type classes pattern ?

2015-03-25 Thread bearophile via Digitalmars-d-learn
s and learn. They are sometimes tricky to get right, but it's not a problem of ugly syntax. I wondered if you could check statically that the type could implement an interface *if it wanted to* that is, without inheriting it... Template constraints don't require inheritance. Bye, bearophile

Re: Do strings with enum allocate at usage point?

2015-03-18 Thread bearophile via Digitalmars-d-learn
thing that allocates inside that function. Bye, bearophile

Re: How to generate a random string ...

2015-03-16 Thread bearophile via Digitalmars-d-learn
Robert burner Schadek: ... from all Unicode characters in an idiomatic D way? Perhaps by rejection? I mean, generating a uint, test if it's a character and repeat until the result is true. Bye, bearophile

Re: get from tuple by type

2015-03-15 Thread bearophile via Digitalmars-d-learn
u are experiencing those problems it's probably the way D/Phobos to tell you to not use basic tuples for your purpose. Use tuples with named fields (or even structs). Take also a look at Algebraic in std.variant. Bye, bearophile

Re: get from tuple by type

2015-03-15 Thread bearophile via Digitalmars-d-learn
Charles Cooper: Is there a better way to do this? Can you show some use cases for this, and isn't "foo[1]" better? Bye, bearophile

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread bearophile via Digitalmars-d-learn
dnewer: but,C# cant compiled to native code. Soon you will be able to compile C# natively. Bye, bearophile

Re: Compilation changes

2015-03-13 Thread bearophile via Digitalmars-d-learn
ot; "Proposal : aggregated dlang git repository" "dmd 2.066.1 cannot build phobos 2.066.1" I will try to get something out of those threads, thank you :-) Bye, bearophile

Compilation changes

2015-03-13 Thread bearophile via Digitalmars-d-learn
="" "OPT=-o" "DEBUG=" "LFLAGS=-L/delexe/la" dmd.exe run idgen Error: 'run' not found --- errorlevel 1 --- errorlevel 1 So is Dmitry (or someone else) willing and able to tell me how to fix my compilation script and what to do? Thank you, bye, bearophile

Re: Int to float?

2015-03-06 Thread bearophile via Digitalmars-d-learn
Ola Fosheim Grøstad: D claims to follow C, so using unions for type punning is ultimately implementation defined. I am not sure if D is the same as C regarding this. Bye, bearophile

[rosettacode] std.container.DList problems

2015-03-04 Thread bearophile via Digitalmars-d-learn
lst.strandSort) write(e, " "); } Now it gives a runtime error like "phobos\std\container\dlist.d(329): DList.front: List is empty". I think the cause is that "list = leftover;" has a different semantics. Is this a regression fit for Bugzilla? Bye, bearophile

Re: "is" expression and type tuples

2015-03-04 Thread bearophile via Digitalmars-d-learn
Jack Applegame: On Tuesday, 3 March 2015 at 17:49:24 UTC, bearophile wrote: That's 1 + n-1 :-) Could you please explain what does '1 + n-1' mean? This is your code: template Is(ARGS...) if(ARGS.length % 2 == 0) { enum N = ARGS.length/2; static if(N == 1) enum Is = is

Re: "is" expression and type tuples

2015-03-03 Thread bearophile via Digitalmars-d-learn
Jack Applegame: or use recursion (with splitting in two, and not 1 + n-1). Bye, bearophile I already have one: template Is(ARGS...) if(ARGS.length % 2 == 0) { enum N = ARGS.length/2; static if(N == 1) enum Is = is(ARGS[0] : ARGS[1]); else enum Is = is(ARGS[0] : ARGS[N]) &

Re: "is" expression and type tuples

2015-03-03 Thread bearophile via Digitalmars-d-learn
, and not 1 + n-1). Bye, bearophile

Re: Implicit fall through not detected (Example from lex.html)

2015-03-03 Thread bearophile via Digitalmars-d-learn
to be an error, but in D we introduce errors slowly. Bye, bearophile

Re: UFCS on template alias ?

2015-02-21 Thread bearophile via Digitalmars-d-learn
Baz: Is this a normal behaviour ? Try to move the definition of "poly" to module-level scope. This is a design decision to avoid other troubles. Bye, bearophile

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread bearophile via Digitalmars-d-learn
Mayuresh Kathe: Should I choose DMD or go with GDC? It's a good idea to use all available compilers. LDC and DMD are both useful. Every one of them has advantages and disadvantages. Bye, bearophile

Re: Mimicking C++'s indexing behavior in D associative arrays

2015-02-18 Thread bearophile via Digitalmars-d-learn
Rikki Cattermole: Foo*[string] bar; Foo v = *bar.grab("mykey"); Is this the setdefault of Python dicts? If this need is strong a new function could be added to Phobos (or even druntime if you want to reduce the number of hash computations). Bye, bearophile

Re: what is the offical way to handle multiple list in map() ?

2015-02-16 Thread bearophile via Digitalmars-d-learn
gt; "eat " ~ a)(a)` )([fruits, vegies]); Better to use another lambda inside, instead of that string. Bye, bearophile

Re: ranges reading garbage

2015-02-15 Thread bearophile via Digitalmars-d-learn
void main() { foo([1,2,3,4,5,6,7,8], [0.1,0.2], [10,20,30,40]); } What a fun program :-) Bye, bearophile

Re: ranges reading garbage

2015-02-15 Thread bearophile via Digitalmars-d-learn
. In future this kind of bugs will be hopefully avoided by a better tracking of the memory. I am not sure if http://wiki.dlang.org/DIP69 is able to avoid this bug, if it can't, then DIP69 needs to be improved. Bye, bearophile

Re: What is the Correct way to Malloc in @nogc section?

2015-02-13 Thread bearophile via Digitalmars-d-learn
hrow away your work just for a comment... be tolerant and be good. Bye, bearophile

Re: Number of Bits Needed to Represent a Zero-Offset Integer

2015-02-13 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: So it could be called ilog2? Perhaps floorIlog2? Isn't ilog2 a different function? Bye, bearophile

Re: Number of Bits Needed to Represent a Zero-Offset Integer

2015-02-13 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: Maybe that could be the basis of a better name? Right. Bye, bearophile

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread bearophile via Digitalmars-d-learn
I suggest you to read how a mark&sweep GC works, or better to implement a bare-bones mark&sweep GC in C language yourself for Lisp-like cons cells, you only need 100 lines of code or so to do it. Bye, bearophile

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread bearophile via Digitalmars-d-learn
Tobias Pankrath: Why should splitter.front allocate? I think that front was able to throw Unicode exceptions, that require the GC. But I think later they have become asserts, that don't require the GC. Bye, bearophile

Re: Number of Bits Needed to Represent a Zero-Offset Integer

2015-02-13 Thread bearophile via Digitalmars-d-learn
scriptive name? Bye, bearophile

Re: To write such an expressive code D

2015-02-10 Thread bearophile via Digitalmars-d-learn
mmutable b; 0 .. 2) foreach (immutable c; 0 .. 2) writefln("%d xor %d xor %d = %d", a, b, c, tuple(a, b, c).f); } Bye, bearophile

Re: To write such an expressive code D

2015-02-10 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: Please help. This starts to look like homework :-) Bye, bearophile

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread bearophile via Digitalmars-d-learn
switching off swap as result we get ~200 MB of "dead data" in RAM, which can be released by rebooting. How i can resolve it? Look for CTFE code, perhaps some of it is excessive. You can convert some of it to run-time in a module-level static this(). Bye, bearophile

Re: "cannot deduce function from argument types" issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
ted: ... where you say 'More DRY' above, are you referring to I was referring to both, but mostly to the typeof. It's more DRY (http://en.wikipedia.org/wiki/Don%27t_repeat_yourself ). You are stating only once the type of the return variable. This is less bug-prone. Bye, bearophile

Re: Classes and @disable this()

2015-02-10 Thread bearophile via Digitalmars-d-learn
I think this can be filed in Bugzilla as diagnostic enhancement: class Foo { @disable this(); this(int i) {} } void main() {} https://issues.dlang.org/show_bug.cgi?id=14163 Bye, bearophile

Re: "cannot deduce function from argument types" issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
void bar(size_t N)(int[N] a, int[N ^ 2] b) {} I meant: void bar(size_t N)(int[N] a, int[N ^^ 2] b) {}

Re: "cannot deduce function from argument types" issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
] b) {} void main() { int[2] a = [1, 2]; int[4] b = [1, 2, 3, 4]; foo(a, b); bar(a, b); } So perhaps my suggestion to file an enhancement request is not a good idea... Bye, bearophile

Re: "cannot deduce function from argument types" issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
() { auto values = [0.0, 3.0, -1.0, 5.0]; auto result = testFunc(values, 8.8); } The D compiler seems unable to compute ElementType!R in the function signature. If I am right, then this seems worth an enhancement request. Bye, bearophile

Re: How to write similar code D?

2015-02-10 Thread bearophile via Digitalmars-d-learn
weak in optimizing well such kind of code... I think D compilers handle built-in associative arrays in a very straight way. Bye, bearophile

Re: How to write similar code D?

2015-02-09 Thread bearophile via Digitalmars-d-learn
more like this in D using the latest version of the compiler: void main() { import std.stdio, std.range, std.algorithm, std.typecons; iota(2, 12) .map!(c => tuple(c ^^ 2 - 1, c ^^ 2 + 1, 2 * c)) .each!(x => writefln("%3d%4d%4d", x[])); } Bye, bearophile

Re: primitive type variables not nullable ?

2015-02-08 Thread bearophile via Digitalmars-d-learn
Tobias Pankrath: Check for null with (x is null) not via printing to stdout. In most cases instead of checking dynamic arrays for null, it's better to use std.array.empty. Bye, bearophile

Re: Template constructor in a non-template struct.

2015-02-08 Thread bearophile via Digitalmars-d-learn
tion2 } struct Boring { this(E Opt = E.option1)(int arg1, int arg2) {} } void main() { auto a = Boring().__ctor!(E.option2)(1, 2); } Bye, bearophile

Re: Classes and @disable this()

2015-02-08 Thread bearophile via Digitalmars-d-learn
fra: However making it a compiler error would be far, far better I think this can be filed in Bugzilla as diagnostic enhancement: class Foo { @disable this(); this(int i) {} } void main() {} Bye, bearophile

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread bearophile via Digitalmars-d-learn
e the first item equal to the given one. You can then add a second function that removes at a given index (like removeAt). Bye, bearophile

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread bearophile via Digitalmars-d-learn
Tobias Pankrath: Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove Unfortunately it's one of the worst designed functions of Phobos: https://issues.dlang.org/show_bug.cgi?id=10959 Bye, bearophile

Re: how can I get a reference of array?

2015-02-05 Thread bearophile via Digitalmars-d-learn
zhmt: Will arr.ptr change in the future? As the array add more members , it need more memroy, then remalloc may be called, the pointer maybe change, then the stored pointer will be invalid. Will this happen? Yes, it can happen. Bye, bearophile

Re: Conway's game of life

2015-02-03 Thread bearophile via Digitalmars-d-learn
t be immutable by default because otherwise programmers often don't bother making them immutable. It's a lost war. Bye, bearophile

Re: Conway's game of life

2015-02-03 Thread bearophile via Digitalmars-d-learn
error of the D compiler to have them disabled by default). foreach(i; 0..INITIALPOP){ It's less bug-prone to make that index immutable: foreach(immutable i; 0 .. initialPop) { Bye, bearophile

Re: how convert the range to slice ?

2015-02-02 Thread bearophile via Digitalmars-d-learn
It's probably better to ask such questions on GitHub (and to open an enhancement request in Bugzilla). Bye, bearophile

Re: Conway's game of life

2015-02-02 Thread bearophile via Digitalmars-d-learn
gedaiu: https://github.com/gedaiu/Game-Of-Life-D A bare-bones implementation: http://rosettacode.org/wiki/Conway%27s_Game_of_Life#Faster_Version The quality of the D GC is not important for a simple Life implementation, you just need two arrays. Bye, bearophile

Re: std.algorithm sort() and reverse() confusion

2015-02-02 Thread bearophile via Digitalmars-d-learn
chains is quite important. Bye, bearophile

Re: Deducing a template retrun parameter type based on an assignment?

2015-01-30 Thread bearophile via Digitalmars-d-learn
Jeremy DeHaan: I figured that it would be smart enough to deduce the parameter type based on the type that it was trying to be assigned to. For that you need languages like Haskell/Rust. D type inference doesn't work from the type something is assigned to. Bye, bearophile

Re: Check if type is from specific template?

2015-01-29 Thread bearophile via Digitalmars-d-learn
Tofu Ninja: Basically what the title says, how do I check if a type T is an instantiation of a specific template? If you have an updated Phobos std.traits.isInstanceOf could be what you look for. Bye, bearophile

Re: how convert the range to slice ?

2015-01-28 Thread bearophile via Digitalmars-d-learn
newbies: void main() { int x; writeln(a); printf("%d\n", x); } Gives: test.d(3,5): Error: 'writeln' is not defined, perhaps you need to import std.stdio; ? test.d(4,5): Error: 'printf' is not defined, perhaps you need to import core.stdc.stdio; ? Bye, bearophile

Re: how convert the range to slice ?

2015-01-28 Thread bearophile via Digitalmars-d-learn
Bye, bearophile

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread bearophile via Digitalmars-d-learn
question, do I ever need to manually release objects I create with new? Usually not. How much advanced do you want to be? :-) Bye, bearophile

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread bearophile via Digitalmars-d-learn
T x, y; } This probably isn't enough to solve your problems, but it's a start. Bye, bearophile

Re: Classical bug

2015-01-27 Thread bearophile via Digitalmars-d-learn
Currently we are implementing a kind of pre-phase: http://wiki.dlang.org/DIP25 And here I have asked for @safe to become the default (Walter seems not against this idea): https://d.puremagic.com/issues/show_bug.cgi?id=13838 Bye, bearophile

Re: Virtual functions and inheritance

2015-01-27 Thread bearophile via Digitalmars-d-learn
Baz: doesn't work. And similarly to the the orginal post: I suggest to read some D documentation first, and program later. Bye, bearophile

Re: Array List object?

2015-01-27 Thread bearophile via Digitalmars-d-learn
And it's named "dynamic array", instead of "Array List object", it's not a class instance. Bye, bearophile

Re: Array List object?

2015-01-27 Thread bearophile via Digitalmars-d-learn
Gan: //Initializing the array tiles = new SBTile[](0); This is often useless. //Clearing the array tiles = []; This doesn't "clear" the array, it rebinds it to a null pointer. Bye, bearophile

Re: static class vs. static struct

2015-01-26 Thread bearophile via Digitalmars-d-learn
erence and they are often on the heap, while a struct is handled by value (or pointer to value). A class has two extra hidden fields. Bye, bearophile

How to tell an identifier is a module?

2015-01-26 Thread bearophile via Digitalmars-d-learn
__traits(allMembers, mixin(__MODULE__)) also yields a module name like object, but then how can you find out that "object" is a module? This doesn't work: void main() { pragma(msg, is(int == int)); pragma(msg, is(object == module)); } Bye, bearophile

Re: Difference between concatenation and appendation

2015-01-25 Thread bearophile via Digitalmars-d-learn
Laeeth Isharc: I think concatenation and append are used as synonyms (the same meaning is meant). a~=b or a=a~b a=a~b always allocates a new array, while a~=b sometimes re-allocates in place. Bye, bearophile

Re: using the full range of ubyte with iota

2015-01-25 Thread bearophile via Digitalmars-d-learn
Dominikus Dittes Scherkl: Because this is useful in more situations, Right, but it's still a cast. And in D you want to minimize the number of usages of casts. The proposed syntax iota!"[]" is cast-safe. Bye, bearophile

Re: using the full range of ubyte with iota

2015-01-25 Thread bearophile via Digitalmars-d-learn
Vlad Levenfeld: What's this about !`[]` and std.range.uniform?? It's not in the documentation. It's an enhancement I have proposed. Bye, bearophile

Re: using the full range of ubyte with iota

2015-01-24 Thread bearophile via Digitalmars-d-learn
Dominikus Dittes Scherkl: Has anyone any idea how to work around this? In Bugzilla I have proposed to solve this problem with this syntax taken from std.range.uniform: iota!"[]"(ubyte.min, ubyte.max) Bye, bearophile

  1   2   3   4   5   6   7   8   9   10   >