On 2015-01-10 at 21:58, bearophile wrote:
Needles is not an array type, it's a type tuple, so withOneOfThese doesn't
accept an array of strings. [...]
So if you really want to pack the strings in some kind of unity, you can do
this as workaround: [...]
I would suggest create a function that d
On 2015-01-25 at 11:42, Tobias Pankrath wrote:
On Sunday, 25 January 2015 at 10:21:34 UTC, Suliman wrote:
But is it good practice to fail with exception during passing unknown
parameters? Maybe std.getopt.config.passThrough should be as default?
I really can't remember Apps that crush if pass
On 2015-01-27 at 23:39, Gan wrote:
I commented out some stuff and it appears my massive memory consumption comes
from my tile.redraw function:
...
Would you know why this is using hundreds of mb of rams?
Looks OK, so probably it is not the cause by itself.
I would add a piece of code to SpaceB
On 2015-01-28 at 03:04, Vladimir Panteleev wrote:
What type is CircleShape?
If it is a class, or otherwise contains pointers, then this is probably the
source of your problem.
class CircleShape : Shape is defined in dsfml.graphics.circleshape, so there's
no going around this...
- Building y
@property auto info() @safe @nothrow @pure @return const { return this; }
It is mesmerizing... (@ _ @)
Error: module app struct std.regex.Thread(DataIndex) is private
Did you import core.thread?
On 2015-01-30 at 11:55, FG wrote:
Error: module app struct std.regex.Thread(DataIndex) is private
Did you import core.thread?
This is silly. Thread is internal to std.regex, yet when importing both
std.regex and core.thread, you still get an error:
src.d(10): Error: core.thread.Thread a
On 2015-01-30 at 12:08, Vladimir Panteleev wrote:
On Friday, 30 January 2015 at 11:04:47 UTC, FG wrote:
Bug or correct behaviour?
Bug: https://issues.dlang.org/show_bug.cgi?id=1238
https://github.com/D-Programming-Language/dmd/pull/3743
The fix is pretty much a one-liner.
Probably 2.067 wil
On 2015-01-30 at 17:07, Paul wrote:
writeln("Sorted, reversed: ", reverse(myVals));
Gives me...
Error: template std.stdio.writeln cannot deduce function from argument types
!()(string, void)
As it should, because reverse returns nothing, void.
But you may wonder what the design choice behind
On 2015-01-30 at 18:42, FG wrote:
But you may wonder what the design choice behind that was that reverse doesn't
return the range itself while sort does (a SortedRange, specifically).
Although, after thinking about it, it makes sense. sort is used mostly to
enforce that something is sorted in
On 2015-02-01 at 16:04, Suliman wrote:
opCmp(in DateTime rhs);
what is rhs?
RHS is probably short of "right hand side", ie. the argument on the right side of
the operator in a binary operator expression. In `a < b` it would be b.
I am trying to do something like this:
if( DateTime.opCmp(dti
On 2015-02-01 at 22:00, gedaiu wrote:
I implemented Conway's game of life in D.
I think you are playing a different game here.
/// Count cell neighbours
long neighbours(Cell myCell, CellList list) {
long cnt;
foreach(cell; list) {
auto diff1 = abs(myCell.x -
On 2015-02-02 at 12:23, FG wrote:
Cell(0,3) is not a neighbour bit fits the (diff1 == 1 || diff2 == 1) criterion.
s/bit/but/
Bloody Thunderbird has sent a reply to the OP and not to the NG.
On 2015-02-02 at 11:45, gedaiu wrote:
I don't think that the line of code is wrong. If use && the function will check
for neighbours only on diagonals. Having || allows the search on the vertical and
horizontal axis and diagonals
On 2015-02-02 at 13:16, irtcupc wrote:
The manual section about interfacing from c states that "type[]" is
inter-compatible from C to D,
however, I face this strange case:
- C declaration:
char identifier[64];
- D declaration:
char[64] identifier;
- the result is only correct if i slice by (
On 2015-02-02 at 14:40, irtcupc wrote:
On Monday, 2 February 2015 at 13:34:28 UTC, ketmar wrote:
struct _Disasm {
align(1):
the difference is that `align` before struct tells how structure should
be packed (i.e. when you have `_Disasm[2] arr`). and `align` *inside*
struct tells compiler how
On 2015-02-03 at 19:53, Foo wrote:
How can I do that without any GC allocation? Nothing in std.file seems to be
marked with @nogc
I'm asking since it seems very complicated to do that with C++, maybe D is a
better choice, then we would probably move our whole project from C++ to D.
Looks lik
On 2015-02-03 at 20:50, Tobias Pankrath wrote:
Use std.utf.validate instead of decode. It will only allocate one exception if
necessary.
Looks to me like it uses decode internally...
But Foo, do you have to use @nogc? It still looks like it's work in progress,
and lack of it doesn't mean that
On 2015-02-04 at 00:07, Foo wrote:
How would I use decoding for that? Isn't there a way to read the file as utf8
or event better, as unicode?
Well, apparently the utf-8-aware foreach loop still works just fine.
This program shows the file size and the number of unicode glyps, or whatever
they
On 2015-02-04 at 01:56, Namespace wrote:
FILE* f = fopen(filename.ptr, "rb");
fseek(f, 0, SEEK_END);
immutable size_t fsize = ftell(f);
fseek(f, 0, SEEK_SET);
That's quite a smart way to get the size of the file.
I started with std.file.getSize (which obviously isn't mark
On 2015-02-05 at 09:58, bearophile wrote:
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.
Therefore, don't u
On 2015-02-05 at 17:25, bearophile wrote:
It has to be a void function (or perhaps bettter it can return true/false if it
has removed the item, so it becomes @nogc and nothrow).
And it has to remove the first item equal to the given one.
You can then add a second function that removes at a given
On 2015-02-06 at 05:17, Gan wrote:
Oh sweet. Though if one message length is off by even 1 byte, then all future
messages get corrupted?
Yes, but you can easily detect that by adding a magic number and packet
checksum to the header.
On 2015-02-06 at 18:09, Charles wrote:
readString(toBytes!char(['t','e','s','t']),0,4).writeln;
readString(toBytes!string("test"),0,4).writeln;// This is line 39
That second line makes no sense (you didn't provide an array of strings).
Why toBytes!string("test") and not to
On 2015-02-07 at 12:02, Andrey Derzhavin wrote:
If a "destroy" method is used together with GC inside of my app,it makes my app
unstable.
In this case I need to choose how to destroy my objects: 1) always manually by method
"destroy", but without GC; 2) or always automatically by GC, but withou
On 2015-02-07 at 13:47, Kadir Erdem Demir wrote:
auto sum = aArr.reduce!((a,b) => a.count + b.count);
The line above gives
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(770): Error: cannot
implicitly convert expression (__lambda3(result, front(_param_1))) of type int
to A
C:\D\
On 2015-02-08 at 01:20, Mike Parker wrote:
In your case, forget destructors and the destroy method. Just implement a
common method on all of your objects that need cleanup (perhaps name it
'terminate') and call that. This gives you the deterministic destruction that
you want (the same as calli
On 2015-02-08 at 06:36, Mike Parker wrote:
On 2/8/2015 11:32 AM, FG wrote:
On 2015-02-08 at 01:20, Mike Parker wrote:
In your case, forget destructors and the destroy method. Just
implement a common method on all of your objects that need cleanup
(perhaps name it 'terminate') and call that. Thi
On 2015-02-08 at 15:56, mzf wrote:
On Saturday, 7 February 2015 at 06:08:39 UTC, ketmar wrote:
On Sat, 07 Feb 2015 04:30:07 +, Safety0ff wrote:
False pointers, current GC is not precise.
not only that. constantly allocating big chunks of memory will inevitably
lead to OOM due to curr
On 2015-02-08 at 19:15, safety0ff wrote:
On Sunday, 8 February 2015 at 16:23:44 UTC, FG wrote:
2. "auto buf = new byte[](1024*1024*100);"
now the gc can't free this buf.
can i free it by manual?
Yes. import core.memory; GC.free(buf.ptr); // and don't use buf afterwards
That won
On 2015-02-09 at 03:40, Timothee Cour via Digitalmars-d-learn wrote:
Is there a simple way to parse a string as a char?
eg:
unittest{
assert(parseChar(`a`)=='a');
assert(parseChar(`\n`)=='\n'); //NOTE: I'm looking at `\n` not "\n"
// should also work with other forms of characters, see
Of course consuming it dchar by dchar also works:
string s = `\tabŁŃ\r\nx`;
assert(parseDchar(s) == '\t');
assert(parseDchar(s) == 'a');
assert(parseDchar(s) == 'b');
assert(parseDchar(s) == 'Ł');
assert(parseDchar(s) == 'Ń');
assert(parseDchar(s) == '\r');
assert(
On 2015-02-10 at 01:41, bearophile wrote:
auto query = iota(2, 12)
.map!(c => Tuple!(int,"length", int,"height",
int,"hypotenuse")
(2 * c, c ^^ 2 - 1, c ^^ 2 + 1))
.map!(x => "%3d%4d%4d".format(x.height, x.hypotenuse,
On 2015-02-11 at 01:56, bearophile wrote:
Alternative solution closer to the F# code:
import std.stdio, std.algorithm, std.typecons;
int f(T)(T t) if (isTuple!T) {
return t.predSwitch(
tuple(0, 0, 0), 0,
tuple(0, 1, 1), 0,
tuple(1, 0, 1), 0,
tuple(1, 1,
On 2015-02-15 at 19:43, bearophile wrote:
void foo(in float[] data, in float[] xs, in float[] ys) @safe {
iota(0, data.length, ys.length)
.map!(xBase => iota(xBase, xBase + ys.length - 1)
.map!(y => [y, y+ys.length, y+ys.length+1, y+1])
.joiner)
On 2015-02-16 at 18:58, Benjamin Thaut wrote:
Am 16.02.2015 um 18:55 schrieb Jonathan Marler:
Why is the 'in' operator nogc but the index operator is not?
void main() @nogc
{
int[int] a;
auto v = 0 in a; // OK
auto w = a[0]; // Error: indexing an associative
On 2015-02-16 at 22:12, Jonathan Marler wrote:
On Monday, 16 February 2015 at 19:12:45 UTC, FG wrote:
Range violation is an Error, but never mind that. The real question is: given
all the work related to @nogc, wouldn't it be better for such common Errors to
be preallocated and only have file
On 2015-02-17 at 03:35, Jonathan Marler wrote:
On Tuesday, 17 February 2015 at 00:00:54 UTC, FG wrote:
Yes, they would be in TLS. I know exceptions in general are a complex problem,
therefore I limited the comment only to errors, because forbidding the use of
`aa[key]` in @nogc seemed odd (alt
// Assume bar is some associative array of type Foo[string]
Foo* value = key in bar;
if (!value) {
bar[key] = Foo.init;
value = &bar[key];
}
This seems sub-optimal, given that in involves three hashes (two lookups
and one insertion). Is there a more efficient or cleaner way to do so?
S
On 2015-03-05 at 10:42, Kagamin wrote:
string s;
char[] b = cast(char[])asArray();
b[0..s.length] = s[];
It's a bit more complicated than that if you include cutting string for buffers
with smaller capacity, doing so respecting UTF-8, and adding a '\0' sentinel,
since you may want to use the
On 2015-03-05 at 15:18, Kagamin wrote:
On Thursday, 5 March 2015 at 13:57:45 UTC, FG wrote:
void main()
{
string s = "ąćęłńóśźż";
Try with string s = "ąc\u0301ęłńóśźż";
Yeah, I see your point: ą, ąc (missing diacritic), ąć, ąćę, ...
Damn those composite characters!
On 2015-03-06 at 00:25, ketmar wrote:
unicode sux[1].
[1] http://file.bestmx.net/ee/articles/uni_vs_code.pdf
Great article. Thanks, Кетмар
⚠ ∑ ♫ ⚽ ☀ ☕ ☺ ≡ ♛
On 2015-03-08 at 20:26, Meta wrote:
On Sunday, 8 March 2015 at 18:57:38 UTC, Kagamin wrote:
http://dpaste.dzfl.pl/2c8d4a7d9ef0 like this.
What in the world is that code doing? I'm having a hard time wrapping my head
around this.
It's a trick to reuse string internals to store an int.
A stri
On 2015-03-11 at 17:42, Dennis Ritchie wrote:
On Wednesday, 11 March 2015 at 16:08:22 UTC, Kagamin wrote:
A hash table? See http://dlang.org/hash-map.html
That is, the input is a string and, depending on what word it contains, is
called one of the three methods of the class that this line han
On 2015-03-11 at 18:27, Dennis Ritchie wrote:
The same without classes in Lisp:
[...]
And your point was...? I take it, "poor c++" is a hint.
Don't compare apples to oranges.
On 2015-03-21 at 16:05, Ivan Kazmenko wrote:
Generate a 10-character string
[...]
Try to copy it with D scanf and printf:
-
import std.stdio;
void main () {
char [10] a;
scanf ("%s", a.ptr);
printf ("%s\n", a.ptr);
}
-
Only 32767 first characters of the string are
On 2015-03-21 at 21:02, Dennis Ritchie wrote:
In what universe?! Which OS, compiler and architecture?
Windows 8.1 x64, dmd 2.066.1:
That's strange. I cannot recreate the problem on Win7 x64 with dmd 2.066.1,
neither when compiled for 32- nor 64-bit. I have saved the a's to a file and
use inp
On 2015-03-21 at 22:15, FG wrote:
On 2015-03-21 at 21:02, Dennis Ritchie wrote:
In what universe?! Which OS, compiler and architecture?
Windows 8.1 x64, dmd 2.066.1:
That's strange. I cannot recreate the problem on Win7 x64 with dmd 2.066.1,
neither when compiled for 32- nor 64-bit. I have s
On 2015-03-31 at 22:56, Laeeth Isharc wrote:
1mm allocations
2.066: 0.844s
2.067: 0.19s
That is great news, thanks!
OT: it's a nasty financier's habit to write 1M and 1MM instead of 1k and 1M. :P
On 2015-04-01 at 16:52, John Colvin wrote:
On Wednesday, 1 April 2015 at 14:22:57 UTC, Laeeth Isharc wrote:
On Wednesday, 1 April 2015 at 10:35:05 UTC, John Colvin wrote:
On Wednesday, 1 April 2015 at 10:09:12 UTC, FG wrote:
On 2015-03-31 at 22:56, Laeeth Isharc wrote:
1mm allocations
2.066:
50 matches
Mail list logo