On Friday, 16 October 2015 at 09:01:57 UTC, yawniek wrote:
hi,
i'm reading in a stream of data that is deserialized into
individual frames.
a frame is either of:
a) a specific D datastructure ( struct with a few
ulong,string,string[string] etc members), known at compile time
b) json (prefer
On Friday, 16 October 2015 at 10:45:52 UTC, Chris wrote:
Later you call the function with the Lua C API like
"lua_pcall(L, 0, 1, 0);". It's a bit tricky to move things
around on the Lua stack, but you'll get there! ;)
Or you could use LuaD which doesn't require you to mess around
with the rel
On Saturday, 17 October 2015 at 02:03:01 UTC, Shriramana Sharma
wrote:
Ali Çehreli wrote:
http://ddili.org/ders/d.en/const_and_immutable.html#ix_const_and_immutable.parameter,
%20const%20vs.%20immutable
Hi Ali – I take this chance to personally thank you sincerely
for your book which provides
On Tuesday, 3 November 2015 at 01:55:27 UTC, Freddy wrote:
Is there any way I can Unionize range Types?
---
auto primeFactors(T)(T t, T div = 2)
{
if (t % div == 0)
{
return t.only.chain(primeFactors(t / div, div));
}
if (div > t)
{
return [];
}
else
On Tuesday, 3 November 2015 at 08:41:11 UTC, Nordlöw wrote:
Is there a reason why std.algorithm.iteration.filter() doesn't
propagate bidirectional access?
http://dlang.org/phobos/std_algorithm_iteration.html#filterBidirectional
On Tuesday, 3 November 2015 at 23:41:10 UTC, maik klein wrote:
Is it possible to filter variadics for example if I would call
void printSumIntFloats(Ts...)(Ts ts){...}
printSumIntFloats(1,1.0f,2,2.0f);
I want to print the sum of all integers and the sum of all
floats.
//Pseudo code
void pr
On Wednesday, 4 November 2015 at 09:48:40 UTC, maik klein wrote:
Thanks, that is exactly what I wanted to achieve. What is the
performance implication of 'only' in this context? Will it copy
all arguments?
Yes, it will, but just from the stack to a different location on
stack.
On Sunday, 8 November 2015 at 19:57:34 UTC, Freddy wrote:
---
import std.algorithm;
import std.range;
import std.stdio;
void main(){
only(iota(0,4),[1,4,5]).writeln;
}
---
How can I call std.range.only with different range types?
`only` is for creating a range from a list of values. io
On Sunday, 8 November 2015 at 23:08:05 UTC, ParticlePeter wrote:
Hi,
the confusion starts here:
http://dlang.org/function.html#closures
End of paragraph bellow the last delegate example:
"This combining of the environment and the function is called a
dynamic closure."
While according to
htt
On Thursday, 3 December 2015 at 21:04:00 UTC, Nordlöw wrote:
Given
class C
{
// lots of members
}
and a function
f(C c)
{
}
is there a generic way, perhaps through reflection, to reset
(inside f) all members of `c` to their default values?
Something along
On Saturday, 5 December 2015 at 16:28:18 UTC, Chris Wright wrote:
The default constructor doesn't set default field values,
though, which is why my solution involved copying
ClassInfo.init.
Thanks, this is a handy factoid. Reminds me of the whole __dtor
vs __xdtor debacle.
Is there a way to do balanced match with std.regex?
Example (from [1]):
test -> funcPow((3),2) * (9+1)
I want to match the funcPow((3),2) bit, regardless of the depth
of the expression in funcPow(*).
https://stackoverflow.com/questions/7898310/using-regex-to-balance-match-parenthesis
[1]
On Tuesday, 15 December 2015 at 00:22:37 UTC, tsbockman wrote:
I also found `SortedRange.equalRange`, but that sounds like it
has an unreasonable amount of (admittedly O(1)) overhead for
the (extremely common) case in which I am looking for only a
single element, not a range.
If your array do
On Tuesday, 15 December 2015 at 00:31:45 UTC, Jakob Ovrum wrote:
For sorted arrays you won't find any other standard facility
for doing binary search, but the containers RedBlackTree and
BinaryHeap provide something related.
You could also get the upper bound (SortedRange.upperBound) and
calc
On Tuesday, 15 December 2015 at 01:07:32 UTC, Chris Wright wrote:
I don't think so.
std.regex looks like it implements only a deterministic finite
automaton, whereas what you are looking for requires a
push-down automaton. It just so happens that a few popular
regex libraries implement PDAs r
On Wednesday, 16 December 2015 at 20:43:02 UTC, Jack Stouffer
wrote:
...
You can also use return type covariance:
class ReferenceBidirectionalRange(T) : ReferenceForwardRange!T
{
this(Range)(Range r) if (isInputRange!Range) { super(r); }
final override @property typeof(this) save() { r
On Thursday, 17 December 2015 at 03:31:37 UTC, Jeremy DeHaan
wrote:
Hi all. I'm interfacing to some C code which include an opaque
type and some C functions that create and work with a pointer
to that type. I want to wrap up everything in a struct, and the
only thing that seems to bug me is ini
On Thursday, 17 December 2015 at 03:40:02 UTC, Shriramana Sharma
wrote:
In my recent search for D's equivalent of isatty, I found out
that there is a core.sys.posix module only by rgrepping under
/usr/include/dmd. Why isn't there a documentation page
http://dlang.org/phobos/core_sys.html wherea
On Thursday, 17 December 2015 at 03:38:31 UTC, Shriramana Sharma
wrote:
Is there a canonical way to test in D whether stdout/stderr (or
in general, a std.stdio.File) refers to a terminal or not?
https://www.google.co.in/search?q=terminal&sitesearch=dlang.org/phobos turns
out nothing.
I knew o
On Thursday, 17 December 2015 at 04:23:30 UTC, Shriramana Sharma
wrote:
Jakob Ovrum wrote:
As with core.stdc, refer to the
documentation for the equivalent C header.
I only know of even core.stdc's existence since I've been
poking into the Phobos sources. At least the Phobos
documentation s
On Thursday, 17 December 2015 at 04:05:30 UTC, Jeremy DeHaan
wrote:
http://dpaste.com/3FH3W13
Also, I would be wary of lazy initialization. We have bad
experiences with it for AAs and standard containers. A typical
example would be:
void foo(Wrapper w)
{
...
w.doTheThing();
...
On Thursday, 17 December 2015 at 04:05:30 UTC, Jeremy DeHaan
wrote:
Thanks. I guess what bugs me is that I always try to hide the
fact that the API is a wrapper around C stuff, ie, I want to
make people feel as though they're using idiomatic D. Doing
something like this makes it feel like less
On Thursday, 17 December 2015 at 04:05:57 UTC, Adam D. Ruppe
wrote:
On Thursday, 17 December 2015 at 03:59:27 UTC, Jakob Ovrum
wrote:
There are some terminal libraries on Github (like consoled)
but I have to say I think they're uninspiring in terms of
quality and presentation.
Can you be any
On Thursday, 17 December 2015 at 05:02:50 UTC, Shriramana Sharma
wrote:
http://dlang.org/phobos/std_getopt.html has a line in an
example saying exit(1);
Surely this works only if core.stdc.stdlib is imported? Should
the example be modified to show the import?
And is exit() the canonical way
On Thursday, 17 December 2015 at 06:04:14 UTC, Jeremy DeHaan
wrote:
And I guess what I was talking about before is that using a
factory method feels klunky to me. If the things I am wrapping
had been written in D they could use default initialization, so
it feels wrong to do otherwise. I also j
On Thursday, 17 December 2015 at 07:33:36 UTC, Jacob Carlborg
wrote:
I agree with that, but why don't the runtime register a
function with "atexit" that cleans up everything?
I think it might be possible, but it doesn't sound trivial. In
particular, all threads and fibers managed by druntime n
On Monday, 21 December 2015 at 02:03:14 UTC, Shriramana Sharma
wrote:
I'm trying to interface to a C function:
extern(C) const char * textAttrN(const char * specString,
size_t n);
and getting the error:
Error: function .textAttrN without 'this' cannot be const
Please advise as to what I'm d
On Monday, 21 December 2015 at 05:41:31 UTC, Shriramana Sharma
wrote:
Rikki Cattermole wrote:
string myCString = cast(string)ptr[0 .. strLen];
Thanks but does this require that one doesn't attempt to append
to the returned string using ~= or such? In which case it is
not safe, right?
Grow
On Monday, 21 December 2015 at 05:34:07 UTC, Shriramana Sharma
wrote:
Hello. I have the following code:
import std.stdio, std.conv;
extern(C) const(char) * textAttrN(const (char) * specString,
size_t n);
string textAttr(const(char)[] specString)
{
const(char) * ptr = textAttrN(specString.p
On Monday, 21 December 2015 at 05:43:04 UTC, Rikki Cattermole
wrote:
On 21/12/15 6:41 PM, Shriramana Sharma wrote:
Rikki Cattermole wrote:
string myCString = cast(string)ptr[0 .. strLen];
Thanks but does this require that one doesn't attempt to
append to the
returned string using ~= or such
On Monday, 21 December 2015 at 05:39:32 UTC, Rikki Cattermole
wrote:
size_t strLen = ...;
char* ptr = ...;
string myCString = cast(string)ptr[0 .. strLen];
I can't remember if it will include the null terminator or not,
but if it does just decrease strLen by 1.
Strings from C libraries shoul
On Monday, 21 December 2015 at 06:00:45 UTC, Shriramana Sharma
wrote:
I suppose what you mean is, the onus of guaranteeing that
const(char)* refers to a null-terminated string is upon the
person calling the to! function? Yes I understand, and Phobos
documentation does say that using a pointer f
On Monday, 21 December 2015 at 08:35:22 UTC, Jonathan M Davis
wrote:
There's also fromStringz that Jakob suggests using elsewhere in
this thread, but that really just boils down to
return cString ? cString[0 .. strlen(cString)] : null;
So, using that over simply slicing is primarily for
d
On Wednesday, 23 December 2015 at 10:51:52 UTC, earthfront wrote:
I'm using hackerpilot's excellent textadept plugin + DCD, Dfmt,
and Dscanner.
Upon saving files, it produces suggestions, much like warnings
from the compiler.
One suggestion is to use selective imports in local scopes. OK,
I'l
On Tuesday, 22 December 2015 at 17:23:11 UTC, Andrew Chapman
wrote:
On Tuesday, 22 December 2015 at 17:18:16 UTC, cym13 wrote:
On Tuesday, 22 December 2015 at 17:15:27 UTC, Andrew Chapman
wrote:
Sorry if this is a silly question but is the to! method from
the conv library the most efficient way
On Wednesday, 23 December 2015 at 11:21:32 UTC, Jakob Ovrum wrote:
Dynamic memory allocation is expensive. If the string is
short-lived, allocate it on the stack:
See also std.conv.toChars[1] for stringifying lazily/on-demand.
http://dlang.org/phobos/std_conv#toChars
On Saturday, 26 December 2015 at 05:31:59 UTC, Ur@nuz wrote:
On Friday, 25 December 2015 at 20:06:04 UTC, drug wrote:
25.12.2015 17:13, Ur@nuz пишет:
[...]
You can do following http://dpaste.dzfl.pl/41c57f89a5a0
The reason of compile error is your using a range as a
separator, change it
On Tuesday, 26 January 2016 at 15:54:14 UTC, Voitech wrote:
How to handle this correctly?
Make BaseParser the value type of the AA. Parser!Foo and
Parser!Bar are subtypes of BaseParser.
Unlike Java, just `Parser` is not a type but a template. It must
be instantiated to create a type. Java i
On Saturday, 6 February 2016 at 06:29:56 UTC, cy wrote:
Let's say I have a socket, and a file, and I want to send the
contents of that file to the socket. What's the best way to do
that? Yes I'm aware that in Linux, you can use a combination of
a pipe and splice(2) to keep all buffers kernel si
On Monday, 8 February 2016 at 05:59:43 UTC, Enjoys Math wrote:
I have several class members:
Arc[4] arcs;
Arc[4] arcs_2;
and Id like to initialize them with the same function, so how
do I "pass them in" by reference?
void foo(ref Arc[4] arr)
{
…
}
The dimension can of course be templa
On Monday, 8 February 2016 at 06:01:24 UTC, Jakob Ovrum wrote:
On Monday, 8 February 2016 at 05:59:43 UTC, Enjoys Math wrote:
I have several class members:
Arc[4] arcs;
Arc[4] arcs_2;
and Id like to initialize them with the same function, so how
do I "pass them in" by reference?
void foo(
On Tuesday, 9 February 2016 at 12:46:59 UTC, Whirlpool wrote:
Hello,
When you are using a C function (from an external library) that
returns a pointer on char which is the beginning of a string (I
know that C does not have a string type, that they are just
arrays of chars ended by '\0'), is t
On Tuesday, 9 February 2016 at 16:52:09 UTC, Gary Willoughby
wrote:
On Tuesday, 9 February 2016 at 12:50:27 UTC, Jakob Ovrum wrote:
writefln et al sensibly does *not* assume that a pointer to
char is a C string, for memory safety purposes.
Print the result of std.string.fromStringz[1] instead:
On Tuesday, 9 February 2016 at 22:39:14 UTC, Gary Willoughby
wrote:
On Tuesday, 9 February 2016 at 17:02:28 UTC, Jakob Ovrum wrote:
to!string behaving like that was a poor design choice[1].
Please use fromStringz.
[1] https://github.com/D-Programming-Language/phobos/pull/1607
It's not a poor
On Tuesday, 17 June 2014 at 04:32:20 UTC, Jakob Ovrum wrote:
On Monday, 16 June 2014 at 20:49:29 UTC, monarch_dodra wrote:
MyCompare cmp(SortOrder.ASC, 10);
This syntax is not valid D.
It should be:
auto cmp = MyCompare(SortOrder,ASC, 10);
Sorry, that first comma is a typo and should b
On Monday, 16 June 2014 at 20:49:29 UTC, monarch_dodra wrote:
MyCompare cmp(SortOrder.ASC, 10);
This syntax is not valid D.
It should be:
auto cmp = MyCompare(SortOrder,ASC, 10);
On Friday, 25 July 2014 at 18:56:44 UTC, Gecko wrote:
findSplit accepts a predicate but it doesnt compile for me if i
use an other function than ((a,b) => a == b).
Not at the moment. I've been working on a patch that makes the
`findSplit*` family of algorithms as powerful as `find`,
including
On Saturday, 20 September 2014 at 18:59:03 UTC, Nordlöw wrote:
Is there a reason why popFront doesn't automatically return
what front does?
If so I'm still missing a combined variant of pop and popFront
in std.range.
Why isn't such a common operation in Phobos already?
Sometimes after poppi
On Saturday, 1 November 2014 at 11:43:28 UTC, Nordlöw wrote:
On Saturday, 20 September 2014 at 19:23:46 UTC, Jakob Ovrum
wrote:
If you want move semantics, use `moveFront`.
But x.moveFront doesn't modify x.
It does modify `x` as it leaves `front` in a destroyed and
default-initialized state
On Thursday, 5 February 2015 at 06:58:09 UTC, Ali Çehreli wrote:
On 02/04/2015 10:42 PM, zhmt wrote:
Here is a simple code snippet:
With this approach, the allocation of `arr` itself is often
clumsy and error-prone. In this case it is important to note that
`arr` is allocated on the stack an
On Tuesday, 10 February 2015 at 04:44:55 UTC, weaselcat wrote:
Thread title.
interface Itest{
}
class testclass : Itest{
}
void main()
{
import std.typecons;
auto test = RefCounted!Itest(new testclass());
}
If you change the refcounted to type testclass it doesn't
compile because r
On Tuesday, 10 February 2015 at 06:26:39 UTC, weaselcat wrote:
Is there currently an enhancement request open for this on the
bug tracker? I cannot find anything.
I couldn't find it either, so I filed it:
https://issues.dlang.org/show_bug.cgi?id=14168
On Thursday, 12 February 2015 at 23:27:51 UTC, Kitt wrote:
The Exception obviously uses the GC, and would need to be
replaced with a printf or something; however, emplace doesn't
have a @nogc replacement that I know of. What I'd like to know,
from people much more knowledgeable about the ins an
On Thursday, 26 March 2015 at 00:41:50 UTC, Laeeth Isharc wrote:
Yeah, it is not very intuitive. But it works.
Thanks.
Next question - how can I correctly deal with inconsiderately
chosen JSON field names like 'private' (which conflict in a
struct declaration with D language keywords). A ha
On Saturday, 11 April 2015 at 10:50:17 UTC, matovitch wrote:
Hello,
The question is in the title. It should be possible for a
finite random access ranges to perform an indexed foreach no ?
I mean like :
foreach(size_t i = 0, auto ref x; R)
{
/*...*/
}
Why are other foreach statements ov
On Saturday, 11 April 2015 at 12:04:06 UTC, matovitch wrote:
well ldc doesn't compile :
kmeans.d(40): Error: no property 'enumerate' for type 'Range'
With -O -release -inline I get around 2s with foreach and 0.5s
with a simple for.
LDC does not yet support the 2.067 front-end version in whi
std.datetime contains parseRFC822DateTime to convert from an
RFC822/RFC5322 formatted string (ala "Sat, 6 Jan 1990 12:14:19
-0800") to a SysTime.
Does it contain anything for the converse - converting from a
SysTime to "Sat, 6 Jan 1990 12:14:19 -0800"?
If not, should it?
test.d
---
void main()
{
import std.net.curl;
import std.stdio;
writeln(get("http://google.com";));
}
---
rdmd -g test.d
---
std.net.curl.CurlException@std\net\curl.d(3691): couldn't resolve
host name on handle 26B4878
0x0040572A in pure @safe void
std.exception
On Tuesday, 21 April 2015 at 10:28:32 UTC, Jonathan M Davis wrote:
On Tuesday, April 21, 2015 08:14:10 Jakob Ovrum via
Digitalmars-d-learn wrote:
std.datetime contains parseRFC822DateTime to convert from an
RFC822/RFC5322 formatted string (ala "Sat, 6 Jan 1990 12:14:19
-0800") to
On Wednesday, 29 April 2015 at 14:46:04 UTC, Per Nordlöw wrote:
On Tuesday, 28 April 2015 at 23:09:27 UTC, Per Nordlöw wrote:
On Tuesday, 28 April 2015 at 16:20:24 UTC, Per Nordlöw wrote:
I update my Github repo. I had forgotten to push my latest
changes.
I solved it.
I started working on
On Sunday, 3 May 2015 at 05:20:34 UTC, Ali Çehreli wrote:
We know that 'in' is "equivalent to const scope":
http://dlang.org/function.html#parameters
So, the constness of 'in' is transitive as well, right?
Ali
Of course, there's no concept of non-transitive const in D:
struct S
{
char
On Tuesday, 12 May 2015 at 13:30:22 UTC, Idan Arye wrote:
A little hacky, but how about casting it to a static array?
http://dpaste.dzfl.pl/d0059e6e6c09
This PR[1] achieves this without making a copy.
[1] https://github.com/D-Programming-Language/phobos/pull/3198
On Saturday, 16 May 2015 at 09:36:30 UTC, Per Nordlöw wrote:
After having written a lot of text pattern matching functions
using Phobos' findSplit, findSplitBefore, findSplitAfter, and
some more I've written myself I've come to the conclusion that
I would like to enhance these functions to inst
On Saturday, 16 May 2015 at 10:28:11 UTC, Per Nordlöw wrote:
Nice! Should I make a PR?
I think that would be very welcome.
On Friday, 11 September 2015 at 13:09:33 UTC, Laeeth Isharc wrote:
obviously it's trivial to do with a little aa cache. and I
know I can memoize a function, and turn the memoized version
into an infinite range. but suppose I have a lazy function
that returns a finite range, and its expensive
On Thursday, 10 September 2015 at 18:01:10 UTC, Russel Winder
wrote:
Is there an easy way of knowing when you do not have to
initialize the D runtime system to call D code from, in this
case, Python via a C adapter?
I naïvely transformed some C++ to D, without consideration of D
runtime syste
On Sunday, 13 September 2015 at 10:10:32 UTC, Jakob Ovrum wrote:
On Thursday, 10 September 2015 at 18:01:10 UTC, Russel Winder
wrote:
Is there an easy way of knowing when you do not have to
initialize the D runtime system to call D code from, in this
case, Python via a C adapter?
I naïvely tr
On Friday, 18 September 2015 at 13:18:23 UTC, Jacob Carlborg
wrote:
On 2015-09-16 12:36, Marc Schütz wrote:
Wouldn't the following behaviour be more useful as a default?
abstract class Foo {
void bar1() { } // non-abstract, obviously
void bar2();// abstract,
68 matches
Mail list logo