On Tuesday, 19 May 2015 at 00:31:50 UTC, Freddy wrote:
Sorry mis-phrased my question,
Who do you allocate a pointer to an associative
array(int[string]*).
Ignoring the why for a moment, one trick is to place it in an
array literal so it's heap allocated. This requires writing an
associative
On Tuesday, 19 May 2015 at 00:00:30 UTC, Meta wrote:
On Monday, 18 May 2015 at 23:55:40 UTC, Freddy wrote:
How do you allocate an associative array on the heap?
void main(){
alias A=int[string];
auto b=new A;
}
$ rdmd test
test.d(4): Error: new can only create structs,
On Monday, 18 May 2015 at 23:55:40 UTC, Freddy wrote:
How do you allocate an associative array on the heap?
void main(){
alias A=int[string];
auto b=new A;
}
$ rdmd test
test.d(4): Error: new can only create structs, dynamic arrays
or class objects, not int[string]'s
F
On Mon, 18 May 2015 23:55:38 +, Freddy wrote:
> How do you allocate an associative array on the heap?
>
> void main(){
> alias A=int[string];
> auto b=new A;
> }
>
> $ rdmd test test.d(4): Error: new can only create structs, dynamic
> arrays or class objects, not int[stri
On Tuesday, 19 May 2015 at 00:00:30 UTC, Meta wrote:
A b = []; //No allocation yet, b is null
Whoops, you actually can't assign the empty array literal to an
AA. This line should be:
A b;
Which has the exact same effects.
How do you allocate an associative array on the heap?
void main(){
alias A=int[string];
auto b=new A;
}
$ rdmd test
test.d(4): Error: new can only create structs, dynamic arrays or
class objects, not int[string]'s
Failed: ["dmd", "-v", "-o-", "test.d", "-I."]
On Monday, 18 May 2015 at 21:35:44 UTC, Per Nordlöw wrote:
void yield(T)(ref T value)
{
mixin("alias caller = " ~ caller ~ ";");
}
doesn't work across module boundaries not even for
`__PRETTY_FUNCTION__`.
Do we need need to fix the compiler, Walter?! ;)
You have to impor
On Monday, 18 May 2015 at 21:30:23 UTC, Per Nordlöw wrote:
On Monday, 18 May 2015 at 21:04:19 UTC, Per Nordlöw wrote:
To clarify: Instead of *string* `__FUNCTION__` I instead want
a reference to the *symbol* of the calling function scope
typically passed as an alias parameter. We could of cours
On Monday, 18 May 2015 at 21:04:19 UTC, Per Nordlöw wrote:
To clarify: Instead of *string* `__FUNCTION__` I instead want a
reference to the *symbol* of the calling function scope
typically passed as an alias parameter. We could of course
always solve it with a mixin but that is 6+1 characters t
On Monday, 18 May 2015 at 21:00:20 UTC, Per Nordlöw wrote:
Is this doable somehow?
To clarify: Instead of *string* `__FUNCTION__` I instead want a
reference to the *symbol* of the calling function scope typically
passed as an alias parameter. We could of course always solve it
with a mixin b
As a follow up to the most
http://forum.dlang.org/thread/miri9k$2p5$1...@digitalmars.com
I'm now very much interested in finding a way to make yield()
capture the UDAs of its caller. That is instead of
void yield(T)(ref T value)
I want it to get a hold of the UDAs of the calling function and
On 05/18/2015 11:52 AM, Steven Schveighoffer wrote:
> Also note that the longest slice doesn't necessarily have access to
> appending. All that is required is that the slice end lands on the array
> end:
That explains a lot. Thanks.
Ali
On 5/18/15 2:45 PM, Ali Çehreli wrote:
Exactly! That recent discovery of mine made me come up with this
guideline: "Never append to a parameter slice."
I think this may not be an appropriate guideline. It's perfectly fine to
append to a parameter slice. You just need to leave it the way you f
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY
'password' WITH GRANT OPTION;
p.s. this command return my: "Affected rows: 0 "
Do you see some stack trace on crash?
No. I checked on 2 PC and it's not look like my issue, because
result is totally same. If I change void main() to vibe
On 5/18/15 2:40 PM, Ali Çehreli wrote:
On 05/18/2015 11:19 AM, John Colvin wrote:> On Monday, 18 May 2015 at
17:43:50 UTC, Ali Çehreli wrote:
>> On 05/18/2015 05:26 AM, John Colvin wrote:
>>> On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote:
On Monday, 18 May 2015 at 10:24:25 UTC,
On Monday, 18 May 2015 at 17:14:46 UTC, Steven Schveighoffer
wrote:
capacity is analogous to the number of elements in the vector
(as returned by array-dimension according to
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node162.html).
arr.length is analogous to the fill pointer.
example:
i
On 05/18/2015 10:52 AM, Steven Schveighoffer wrote:
> On 5/18/15 1:43 PM, Ali Çehreli wrote:
>> void main()
>> {
>> auto a = new int[20];
>> foo(a);
>> //can't now append to a
>
> Well, sure you can :)
>
> a ~= 5; // works fine
>
> But I understand you mean that an append to 'a' w
On 05/18/2015 11:19 AM, John Colvin wrote:> On Monday, 18 May 2015 at
17:43:50 UTC, Ali Çehreli wrote:
>> On 05/18/2015 05:26 AM, John Colvin wrote:
>>> On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote:
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
> No, afrai
On Mon, 18 May 2015 14:41:19 +, Chris wrote:
> On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote:
>> On Mon, 18 May 2015 14:30:42 +, Chris wrote:
>>
>>> The following
>>>
>>> string[string] myarray = ["key":"value"];
>>> string entry;
>>> entry = myarray["key"]; // => vgc: indexing an
On Monday, 18 May 2015 at 17:43:50 UTC, Ali Çehreli wrote:
On 05/18/2015 05:26 AM, John Colvin wrote:
On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote:
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
No, afraid not. Function capacity is not an analogue of
fill-pointers!
On 5/18/15 1:43 PM, Ali Çehreli wrote:
On 05/18/2015 05:26 AM, John Colvin wrote:
On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote:
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
No, afraid not. Function capacity is not an analogue of fill-pointers!
It's exactly the sa
On 05/18/2015 05:26 AM, John Colvin wrote:
On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote:
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
No, afraid not. Function capacity is not an analogue of fill-pointers!
It's exactly the same.
But in D capacity is affected by o
On Sunday, 17 May 2015 at 21:34:21 UTC, tcak wrote:
[code]
void test(D)( const D data ) if( is(D: shared(char[]) ) ) { }
void main() {
char[] text = new char[4];
text[0] = 'a'; text[1] = 'b'; text[2] = 'c'; text[3] = 'd';
auto t = cast( shared(const(char[])) )tex
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote:
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote:
Hi,
In Common Lisp, there is such a thing as a fill-pointer
(Example 5):
http://www.tutorialspoint.com/lisp/lisp_
On Sunday, 17 May 2015 at 18:49:40 UTC, dan wrote:
Is it possible to define a class F so that
auto f=new F();
writeln("The value of f at 7 is ",f(7));
compiles and works as expected?
So the idea would be to be able to use notation like
f(7)
instead of
f.eval(7)
or something along
On Monday, 18 May 2015 at 13:14:38 UTC, Steven Schveighoffer
wrote:
It's annoying to have to dup each one.
Yes, it's really annoying. However, the problem can be solved as
follows:
http://forum.dlang.org/thread/owxweucyzjwugpjwh...@forum.dlang.org?page=2#post-cqjevoldkqdkmdbenkul:40forum.dlan
On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote:
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
No, afraid not. Function capacity is not an analogue of
fill-pointers!
It's exactly the same.
But in D capacity is affected by other things.
auto a = new int[20];
auto b =
On 2015-05-15 17:26:50 +, Ali Çehreli said:
On 05/15/2015 09:45 AM, Robert M. Münch wrote:
> Is there a way I can build an ENUM from within the FOREACH? What I want
> to achive is, that I would like to use:
>
> final switch (myEnum) ...
Sorry, I don't understand your question. :(
Do y
[code]
void test(D)( const D data ) if( is(D: shared(char[]) ) ) { }
void main() {
char[] text = new char[4];
text[0] = 'a'; text[1] = 'b'; text[2] = 'c'; text[3] = 'd';
auto t = cast( shared(const(char[])) )text[1..2];
test( t );
}
[/code]
Error Messag
On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote:
On Mon, 18 May 2015 14:30:42 +, Chris wrote:
The following
string[string] myarray = ["key":"value"];
string entry;
entry = myarray["key"]; // => vgc: indexing an associative
array may
cause GC allocation
Why is _accessing_ an assoc t
On 5/15/15 2:19 PM, ref2401 wrote:
On Friday, 15 May 2015 at 16:30:29 UTC, Steven Schveighoffer wrote:
On 5/15/15 12:04 PM, ref2401 wrote:
What is the difference between 'const' and 'in' parameter storage
classes?
When should I use 'const' or 'in'?
The documentation says 'in' is the same as 'c
Is it possible to define a class F so that
auto f=new F();
writeln("The value of f at 7 is ",f(7));
compiles and works as expected?
So the idea would be to be able to use notation like
f(7)
instead of
f.eval(7)
or something along those lines.
My guess is no, it is impossible to d
who's never had to do this:
---
if (comparison)
{
statement;
break;
}
---
ans then thought it's a pity to open/closes the braces just for a
simple statement. Would it be possible to have a template to
simplify this to:
---
if (comparison)
Break!(expression);
---
or even at the l
On Monday, 18 May 2015 at 09:23:26 UTC, tcak wrote:
On Monday, 18 May 2015 at 09:18:33 UTC, ParticlePeter wrote:
I get the point to an array from a c function, the data size
from another function. The data should be only readable at the
D side, but I would like to use it as a D slice without
c
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
It seems to be nonsense. But this is nonsense, ideal for
buffers. If the buffer is implemented as an array, then fill
pointer just marks the boundary of the filled part of the
buffer, and adding a buffer (moving away from the fill
p
still can't get it's work :(
On Monday, 18 May 2015 at 09:23:26 UTC, tcak wrote:
On Monday, 18 May 2015 at 09:18:33 UTC, ParticlePeter wrote:
I get the point to an array from a c function, the data size
from another function. The data should be only readable at the
D side, but I would like to use it as a D slice without
c
On 05/17/2015 11:49 AM, dan wrote:
i can't find it on the internet
There is the following short section as well:
http://ddili.org/ders/d.en/operator_overloading.html#ix_operator_overloading.opCall
Ali
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote:
Hi,
In Common Lisp, there is such a thing as a fill-pointer
(Example 5):
http://www.tutorialspoint.com/lisp/lisp_arrays.htm
Does D some equivalent?
Fill pointers, combined with the various helper functions (e.g.
vector-push) and
On 5/18/15 6:24 AM, Dennis Ritchie wrote:
On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote:
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote:
Hi,
In Common Lisp, there is such a thing as a fill-pointer (Example 5):
http://www.tutorialspoint.com/lisp/lisp_arrays.htm
Does D som
On Monday, 18 May 2015 at 12:49:56 UTC, Kagamin wrote:
Filling a buffer is usually done this way:
http://dlang.org/phobos/std_stdio.html#.File.rawRead
Here such example, the task. There is a flow stream, associated,
for example, with any socket. It wrote several bytes at a time.
To once again
On Sunday, 17 May 2015 at 10:24:43 UTC, Suliman wrote:
I am using this driver for access to MariaDB
http://code.dlang.org/packages/ddbc
The problem that it's work fine when it's used from desktop
App, but when I try to run it's from vibed app i get "Access
Violation".
In my.ini I added string
On Monday, 18 May 2015 at 14:43:33 UTC, Steven Schveighoffer
wrote:
Right, you'd apply the map/array combo to each element:
Yes, I knew it.
alias m = map!(a => a.dup); // too bad can't do array as well
auto s = [m(["foo", "baz"]).array, m(["bar", "test"]).array];
Or to get even more crazy:
On 5/18/15 9:55 AM, Dennis Ritchie wrote:
On Monday, 18 May 2015 at 13:14:38 UTC, Steven Schveighoffer wrote:
It's annoying to have to dup each one.
Yes, it's really annoying. However, the problem can be solved as follows:
http://forum.dlang.org/thread/owxweucyzjwugpjwh...@forum.dlang.org?page
Am Mon, 18 May 2015 09:51:48 +
schrieb "John Colvin" :
> No need to worry about the GC here, it only scans the stack and
> its own heap (unless you specifically add a new root).
And even if you add a root it wont free anything it did not
allocate itself! You could even append to your C array
Am Mon, 18 May 2015 09:05:51 -0400
schrieb Steven Schveighoffer :
> On 5/15/15 2:19 PM, ref2401 wrote:
> > On Friday, 15 May 2015 at 16:30:29 UTC, Steven Schveighoffer wrote:
> >> On 5/15/15 12:04 PM, ref2401 wrote:
> >>> What is the difference between 'const' and 'in' parameter storage
> >>> clas
The following
string[string] myarray = ["key":"value"];
string entry;
entry = myarray["key"]; // => vgc: indexing an associative array
may cause GC allocation
Why is _accessing_ an assoc treated as indexing it?
On 5/17/15 5:15 AM, Dennis Ritchie wrote:
This option is also a strange:
char[][] s = ["foo".dup, "bar".dup];
s[1][1] = 't';
In my opinion, you need to add to D keyword mutable.
It's annoying to have to dup each one.
But, you do have a couple other possibilities:
auto s = ["foo".dup, "bar".
On Mon, 18 May 2015 14:30:42 +, Chris wrote:
> The following
>
> string[string] myarray = ["key":"value"];
> string entry;
> entry = myarray["key"]; // => vgc: indexing an associative array may
> cause GC allocation
>
> Why is _accessing_ an assoc treated as indexing it?
it can throw "out o
On Sun, 17 May 2015 10:09:10 +, Daniel Kozak wrote:
> On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote:
>> Is this error an ICE? I think so, because I see the internal filename,
>> but I'm not sure.
>>
>> Error: e2ir: cannot cast malloc(length * 8u) of type void* to type
>> char[]
>
>
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote:
No, afraid not. Function capacity is not an analogue of
fill-pointers!
It's exactly the same.
Lisp-programmer explains the usefulness of fill-pointers as
follows:
"Fill pointer "cuts" the tail of the vector.
In D: .length "cut
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote:
Hi,
In Common Lisp, there is such a thing as a fill-pointer
(Example 5):
http://www.tutorialspoint.com/lisp/lisp_arrays.htm
Does D some equivalent?
Data stored in the array is indicated by the array length
property, use capacity
I get the point to an array from a c function, the data size from
another function. The data should be only readable at the D side,
but I would like to use it as a D slice without copying the data.
Is this possible ?
On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote:
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote:
Hi,
In Common Lisp, there is such a thing as a fill-pointer
(Example 5):
http://www.tutorialspoint.com/lisp/lisp_arrays.htm
Does D some equivalent?
Data stored in the array
On Monday, 18 May 2015 at 09:18:33 UTC, ParticlePeter wrote:
I get the point to an array from a c function, the data size
from another function. The data should be only readable at the
D side, but I would like to use it as a D slice without copying
the data. Is this possible ?
char* dataPtr;
On Monday, 18 May 2015 at 08:46:36 UTC, John Colvin wrote:
On Monday, 18 May 2015 at 06:13:50 UTC, Baz wrote:
who's never had to do this:
---
if (comparison)
{
statement;
break;
}
---
ans then thought it's a pity to open/closes the braces just
for a
simple statement. Would it be poss
On Monday, 18 May 2015 at 06:13:50 UTC, Baz wrote:
who's never had to do this:
---
if (comparison)
{
statement;
break;
}
---
ans then thought it's a pity to open/closes the braces just for
a
simple statement. Would it be possible to have a template to
simplify this to:
---
if (comp
Hi,
In Common Lisp, there is such a thing as a fill-pointer (Example
5):
http://www.tutorialspoint.com/lisp/lisp_arrays.htm
Does D some equivalent?
On Sunday, 17 May 2015 at 18:58:32 UTC, Namespace wrote:
http://dlang.org/operatoroverloading.html#function-call
Like this:
module main;
import std.stdio;
class F
{
int opCall(int value)
{
return value * 2;
}
}
void main(string[] args)
{
auto
Awesome!!
Thanks Gary and namespace (and obviously i gotta improve my
google-fu).
dan
On Sunday, 17 May 2015 at 19:40:10 UTC, Gary Willoughby wrote:
On Sunday, 17 May 2015 at 18:58:32 UTC, Namespace wrote:
http://dlang.org/operatoroverloading.html#function-call
Like this:
module main;
i
60 matches
Mail list logo