Indeed it's confusing.
So AA is a value type that behaves like a pointer/reference.
We can add a rule to the initialization to make AA behave more
like reference types:
If someone `refer` to an unitialized AA, that is, by doing:
```d
string[string] aa;
string[string] bb = aa; // bb
It's an optimization of memory allocation: you can always have a
usable AA without allocating anything for it, so when you fill it
with data, you may want to assign it back to where it should
stay, similar to a slice.
Yes indeed, null initial value is reasonable. My suggestion does
not affect that rationale, but is only based on my observation
that if someone want to `refer` to an AA, he is more likely to
fill it very soon, and he really mean to refer to it. These are
similar concerns:
- create a null AA,
On Thursday, 7 August 2014 at 15:11:48 UTC, TJB wrote:
I am trying to read data in from a csv file into a struct, and
then turn around and write that data to binary format.
Here is my code:
import std.algorithm;
import std.csv;
import stdio = std.stdio;
import std.stream;
align(1) struct
I am trying to read data in from a csv file into a struct, and
then turn around and write that data to binary format.
Here is my code:
import std.algorithm;
import std.csv;
import stdio = std.stdio;
import std.stream;
align(1) struct QuotesBin
{
int qtim;9 int bid;
int ofr;
int
On Thursday, 7 August 2014 at 15:14:00 UTC, TJB wrote:
align(1) struct QuotesBin
{
int qtim;
int bid;
int ofr;
int bidsiz;
int ofrsiz;
short mode;
char[1] ex;
char[4] mmid;
}
Thanks!
(You forgot to include the error. For other readers: It fails to
compile with template
On Thu, 07 Aug 2014 16:05:16 +, seany wrote:
obviously there are ways like counting the match length, and then using
the maximum length, instead of breaking as soon as a match is found.
Are there any other better ways?
You're not really using regexes properly. You want to greedily
On Thursday, 7 August 2014 at 16:05:17 UTC, seany wrote:
Cosider please the following:
string s1 = PREabcdPOST;
string s2 = PREabPOST;
string[] srar = [ab, abcd];
// this can not be constructed with a particular order
foreach(sr; srar)
{
auto r = regex(sr; g);
auto m = matchFirst(s1,
On Thursday, 7 August 2014 at 16:12:59 UTC, Justin Whear wrote:
On Thu, 07 Aug 2014 16:05:16 +, seany wrote:
obviously there are ways like counting the match length, and
then using
the maximum length, instead of breaking as soon as a match is
found.
Are there any other better ways?
On Thursday, 7 August 2014 at 16:08:01 UTC, TJB wrote:
Thanks Marc. Not sure what to do here. I need to the binary
data to be exactly the number of bytes as specified by the
struct.
How to handle the conversion from string to char[]?
Well, in your CSV data, they don't have the right length,
On Thursday, 7 August 2014 at 16:08:01 UTC, TJB wrote:
Thanks Marc. Not sure what to do here. I need to the binary
data to be exactly the number of bytes as specified by the
struct.
Something else: The `align(1)` on your type definition specifies
the alignment of the entire struct, but has
On Thu, Aug 07, 2014 at 04:49:05PM +, seany via Digitalmars-d-learn wrote:
On Thursday, 7 August 2014 at 16:12:59 UTC, Justin Whear wrote:
On Thu, 07 Aug 2014 16:05:16 +, seany wrote:
obviously there are ways like counting the match length, and then
using the maximum length, instead
(Original discussion:
http://forum.dlang.org/thread/fckwpddiwxonabqaf...@forum.dlang.org#post-pskjgieddhpntzaokohj:40forum.dlang.org)
align(1) struct A
{
align(1):
int qtim;
int bid;
int ofr;
int bidsiz;
int ofrsiz;
short mode;
On Thursday, 7 August 2014 at 17:12:35 UTC, Marc Schütz wrote:
This align the struct as a whole, and all its fields at byte
boundaries. Without the second `align(1)`, there should be a
gap between `mode` and `ex`. Strangely enough, when I test it,
there's none. Will have to ask...
Sorry,
On Thu, 07 Aug 2014 10:22:37 -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
So basically you have a file containing regex patterns, and you want to
find the longest match among them?
// Longer patterns match first patterns.sort!((a,b) = a.length
b.length);
// Build
On Thu, Aug 07, 2014 at 05:33:42PM +, Justin Whear via Digitalmars-d-learn
wrote:
On Thu, 07 Aug 2014 10:22:37 -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
So basically you have a file containing regex patterns, and you want
to find the longest match among them?
//
I want to learn SDL2 and learn D at the same time, for the SDL2
part autocompletion would be very nice.
I've found DCD but can't get it working (not finding symbols or
declarations) at the moment but I was wondering if there are any
alternatives, it's hard to google for d things and emacs,
On Thu, Aug 07, 2014 at 10:42:13AM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
Hmm, you're right. I was a bit disappointed to find out that the |
operator in std.regex (and also in Perl's regex) doesn't do
longest-match but first-match. :-( I had always thought it did
What is the best way to forward a string[] as argument to a
function called through std.concurrency.spawn().
I need this in the following example where I start the vibe.d
event loop in the main thread (the only way I've managed to get
runEventLoop() to work) and run my other program logic in
On Thu, Aug 07, 2014 at 06:23:24PM +, Nordlöw via Digitalmars-d-learn
wrote:
What is the best way to forward a string[] as argument to a function
called through std.concurrency.spawn().
I need this in the following example where I start the vibe.d event
loop in the main thread (the only
On Thursday, 7 August 2014 at 18:33:40 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Thu, Aug 07, 2014 at 06:23:24PM +, Nordlöw via
Digitalmars-d-learn wrote:
What is the best way to forward a string[] as argument to a
function
called through std.concurrency.spawn().
I need this in
On Thursday, 7 August 2014 at 18:38:37 UTC, Marc Schütz wrote:
But this shouldn't be necessary, right? It's a mutable slice to
immutable data, but the slice is passed by value, so no mutable
sharing takes place.
I agree.
I'll use .idup anyhow. For this work I however have to do
void
On Thursday, 7 August 2014 at 18:38:37 UTC, Marc Schütz wrote:
But this shouldn't be necessary, right? It's a mutable slice to
immutable data, but the slice is passed by value, so no mutable
sharing takes place.
The elements of the slice itself are mutable, you can e.g. assign
some other
On 2014-08-07 20:23, Nordlöw wrote:
What is the best way to forward a string[] as argument to a function
called through std.concurrency.spawn().
What about just accessing core.runtime.Runtime.args from the new thread?
--
/Jacob Carlborg
On Thursday, 7 August 2014 at 18:23:26 UTC, Nordlöw wrote:
What is the best way to forward a string[] as argument to a
function called through std.concurrency.spawn().
I need this in the following example where I start the vibe.d
event loop in the main thread (the only way I've managed to get
On Thursday, 7 August 2014 at 19:08:37 UTC, Johannes Blume wrote:
On Thursday, 7 August 2014 at 18:38:37 UTC, Marc Schütz wrote:
But this shouldn't be necessary, right? It's a mutable slice
to immutable data, but the slice is passed by value, so no
mutable sharing takes place.
The elements
On Thursday, 7 August 2014 at 18:16:11 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
https://issues.dlang.org/show_bug.cgi?id=13268
T
Thank you soo much!!
On Wed, Aug 06, 2014 at 12:16:57PM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
On Wed, Aug 06, 2014 at 11:21:51AM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
In any case, what Kenji did was basically to implement support for:
arr[i,j,k,...]; // opIndex
On Tuesday, 12 February 2013 at 01:07:35 UTC, bearophile wrote:
In practice at the moment I am maintaining all the D entries of
Rosettacode.
Here's a candidate for
http://rosettacode.org/wiki/Extensible_prime_generator#D in case
it is preferred to the existing entry:
On Thursday, 7 August 2014 at 15:11:48 UTC, TJB wrote:
Here is a snippet of my csv data:
34220, 37, 371200, 1, 1, 12, N,
34220, 369000, 372500, 1, 11, 12, P,
34220, 37, 371200, 1, 2, 12, N,
I can't help but think somehow that as long as the data is
numbers or words, that scanf would
On Thursday, 7 August 2014 at 17:22:15 UTC, Marc Schütz wrote:
(Original discussion:
http://forum.dlang.org/thread/fckwpddiwxonabqaf...@forum.dlang.org#post-pskjgieddhpntzaokohj:40forum.dlang.org)
I would expect `B` to have a gap between `ex` and `mmid`. AFAIK
the outer `align(1)` only
Still watching this, but the Dconf 2014 bare metal presentation
gets into it a bit...
http://youtu.be/qErXPomAWYI?t=37m20s
32 matches
Mail list logo