On 7/23/15 5:58 PM, jmh530 wrote:
I was looking at
http://dlang.org/concepts.html
where it discusses overloading templates based on constraints. I wanted
to try to overload a template function with another version that does
everything in place. So basically, one has a return and the other
On Thursday, 23 July 2015 at 11:49:05 UTC, cym13 wrote:
On Thursday, 23 July 2015 at 11:15:46 UTC, Enjoys Math wrote:
1. Is the best way to hash a uint[] slice
2. How do you do it?
IIRC, std.digest functions take ubyte[] as input, so to hash a
uint[] I would do the following:
void
On Thursday, 23 July 2015 at 12:10:04 UTC, Enjoys Math wrote:
On Thursday, 23 July 2015 at 11:49:05 UTC, cym13 wrote:
[...]
Thanks. That worked. Here's my code:
module hashtools;
import std.conv;
import std.digest.md;
string uintSliceToHash(const uint[] slice) {
auto md5 = new
1. Is the best way to hash a uint[] slice
2. How do you do it?
On Thursday, 23 July 2015 at 11:15:46 UTC, Enjoys Math wrote:
1. Is the best way to hash a uint[] slice
2. How do you do it?
IIRC, std.digest functions take ubyte[] as input, so to hash a
uint[] I would do the following:
void main(string[] args)
{
import std.conv;
All types are hashable and for your own structs and classes you
can redefine opHash
Here's my code:
module grammar;
class Grammar(T : ulong) {
this(const T[] str) {
auto grammar = str in grammarCache;
if (grammar) {
this = grammar.dup;
} else {
this = approximateSmallestGrammar(str);
grammarCache[str] = this.dup;
On 7/23/15 9:30 PM, Enjoys Math wrote:
Here's my code:
module grammar;
class Grammar(T : ulong) {
this(const T[] str) {
auto grammar = str in grammarCache;
if (grammar) {
this = grammar.dup;
} else {
this =
On Friday, 24 July 2015 at 03:12:43 UTC, Steven Schveighoffer
wrote:
On 7/23/15 9:30 PM, Enjoys Math wrote:
[...]
You're approaching this wrong. Do the lookup before deciding
whether to instantiate a new object:
static Grammar getGrammar(const T[] str) {
if(auto x = str in
On Thursday, July 23, 2015 13:59:11 Steven Schveighoffer via
Digitalmars-d-learn wrote:
On 7/22/15 5:23 AM, Clayton wrote:
How does one represent Duration in only Micro-seconds, or milliseconds.
Trying to measure the execution time of an algorithm and I get 4 ms,
619 μs, and 8 hnsecs , I
On Friday, July 24, 2015 01:30:55 Enjoys Math via Digitalmars-d-learn wrote:
Here's my code:
module grammar;
class Grammar(T : ulong) {
this(const T[] str) {
auto grammar = str in grammarCache;
if (grammar) {
this = grammar.dup;
} else {
I was looking at
http://dlang.org/concepts.html
where it discusses overloading templates based on constraints. I
wanted to try to overload a template function with another
version that does everything in place. So basically, one has a
return and the other doesn't. However, when I run the code,
On Thursday, July 23, 2015 12:56:13 Temtaime via Digitalmars-d-learn wrote:
All types are hashable and for your own structs and classes you
can redefine opHash
It's toHash, actually, but yeah.
- Jonathan M Davis
On Thursday, 23 July 2015 at 01:43:56 UTC, Mike Parker wrote:
On Thursday, 23 July 2015 at 01:39:05 UTC, Mike Parker wrote:
post at [1] where Rainer shared the relevant bits of a batch
Gah, hate it when I forget the links.
[1] http://forum.dlang.org/post/m456t5$2jc4$1...@digitalmars.com
On Thursday, 23 July 2015 at 09:05:12 UTC, Marc Schütz wrote:
It is not safe, but for a different reason: `mt` is already a
_reference_ to the actual object (that's how classes behave in
D). This reference is located in a register or on the stack,
and `mt` is therefore a pointer into the
On 2015-07-23 03:57, Mike Parker wrote:
In your case, rd_kafka_metadata is the name of the struct, but in C
instances would need to be declared like so:
struct rd_kafka_metadata instance;
Since the struct is declared directly in the typedef, is the struct name
actually available?
--
On Thursday, 23 July 2015 at 15:39:15 UTC, Taylor Hillegeist
wrote:
On Thursday, 23 July 2015 at 15:23:07 UTC, Taylor Hillegeist
wrote:
I found this nugget in the sc.ini file!
[Environment32mscoff]
LIB=%@P%\..\lib32mscoff
Apparently i need to create a lib32mscoff folder in
C:\D\dmd2\windows\
On Thursday, 23 July 2015 at 14:56:48 UTC, Taylor Hillegeist
wrote:
On Thursday, 23 July 2015 at 01:43:56 UTC, Mike Parker wrote:
[...]
IT worked! Placing this Batch file in the dmd2\src Folder.
-- BEGIN FILE: BUILD.bat
set
On Thursday, 23 July 2015 at 15:23:07 UTC, Taylor Hillegeist
wrote:
I found this nugget in the sc.ini file!
[Environment32mscoff]
LIB=%@P%\..\lib32mscoff
Apparently i need to create a lib32mscoff folder in
C:\D\dmd2\windows\
Well if its not one thing its always another :)
LINK : fatal
On Wednesday, 22 July 2015 at 09:32:15 UTC, John Colvin wrote:
On Wednesday, 22 July 2015 at 09:23:36 UTC, Clayton wrote:
[...]
The normal way of doing this would be using
std.datetime.StopWatch:
StopWatch sw;
sw.start();
algorithm();
long exec_ms = sw.peek().msecs;
Am
On Wednesday, 22 July 2015 at 04:29:26 UTC, Taylor Gronka wrote:
Hi,
I have a template function, and I want it to do something if
the input variable is a list of structs, and something else if
the input is a struct.
[...]
Take a look at this thread, the poster had the same question:
On 7/22/15 5:23 AM, Clayton wrote:
How does one represent Duration in only Micro-seconds, or milliseconds.
Trying to measure the execution time of an algorithm and I get 4 ms,
619 μs, and 8 hnsecs , I want to sum all these and get total hnsecs or
μs .
I would also appreciate advise on whether
On Thursday, 23 July 2015 at 06:26:28 UTC, Jacob Carlborg wrote:
On 2015-07-23 03:57, Mike Parker wrote:
In your case, rd_kafka_metadata is the name of the struct, but
in C
instances would need to be declared like so:
struct rd_kafka_metadata instance;
Since the struct is declared directly
On 2015-07-23 00:22, nurfz wrote:
I think you got overly complicated answers.
I guess I'm confused as to why the D code isn't acting similar to the
Python code in the sense that you would expect this to reference the
speed property of the current instance and not statically reference
the
On Wednesday, 22 July 2015 at 22:52:22 UTC, John Colvin wrote:
On Wednesday, 22 July 2015 at 22:22:02 UTC, nurfz wrote:
[...]
Fields of classes are not in any way polymorphic in D (this is
the same as C++ and I think java too). Base class members can
be accessed like so:
class Vehicle {
On Wednesday, 22 July 2015 at 17:01:52 UTC, Marc Schütz wrote:
You can probably simply terminate the main thread, which will
send an OwnerTerminated message to all dependent threads. The
threads need to `receive()` this message and terminate.
Not possible here. Main has to run the all the
On Wednesday, 22 July 2015 at 17:17:17 UTC, Frank Pagliughi wrote:
Or, to put it another way, getting threads out of the equation,
is this safe?
class MyThing { ... }
MyThing* create_a_thing() {
MyThing mt = new MyThing();
do_something_with(mt);
return mt;
}
void main() {
On Wednesday, 22 July 2015 at 16:16:36 UTC, John Colvin wrote:
I would send a message to terminate to thread1, which would in
turn send a similar message to any threads it has started, wait
until they've all stopped (maybe with a time-out), then return.
I.e. every thread knows how to
28 matches
Mail list logo