On Sat, 08 Sep 2018 10:22:38 +, SuperPrower wrote:
> Also, is this me and my bad English, or first comment in code in this
> paragraph (linked above, not in the discussion) is supposed to be
> something different? Shouldn't it be reference?
Static arrays are value types, so the values are cop
On Saturday, 8 September 2018 at 10:05:31 UTC, rikki cattermole
wrote:
onReceive:
"The event handler that receives incoming data. Be sure to copy
the incoming ubyte[] since it is not guaranteed to be valid
after the callback returns."
It could be a buffer on the stack, either way, .dup it bef
On 08/09/2018 9:46 PM, SuperPrower wrote:
On Saturday, 8 September 2018 at 09:36:21 UTC, rikki cattermole wrote:
We're going to need to see a minified version of the code to see what
you're doing.
Sure, here it is:
```
auto getBoards()
{
string[] boardList;
auto url = baseUrl ~ "/a
On Saturday, 8 September 2018 at 09:36:21 UTC, rikki cattermole
wrote:
We're going to need to see a minified version of the code to
see what you're doing.
Sure, here it is:
```
auto getBoards()
{
string[] boardList;
auto url = baseUrl ~ "/api/v2/boards";
auto http = HT
On 08/09/2018 9:34 PM, SuperPrower wrote:
I have a function that produces dynamic array of strings. I would like
to return this array from this function. I understand that dynamic
arrays are of reference type, and thus if I try to return array
variable, I will actually return a pointer to the f
I have a function that produces dynamic array of strings. I would
like to return this array from this function. I understand that
dynamic arrays are of reference type, and thus if I try to return
array variable, I will actually return a pointer to the first
element of the array on the heap. Pro
On Saturday, 14 June 2014 at 21:37:51 UTC, Marco Cosentino wrote:
int[] data = [1,2,3,4];// create new array on the
heap
Thanks for the answer.
This is the bit of information I was missing: how to create an
array in the heap.
Is also this a valid way to do so?
int[] data = new int[0
int[] data = [1,2,3,4];// create new array on the
heap
Thanks for the answer.
This is the bit of information I was missing: how to create an
array in the heap.
Is also this a valid way to do so?
int[] data = new int[0];
data ~= [4,2,3,1];
On Saturday, 14 June 2014 at 14:02:52 UTC, Marco Cosentino wrote:
Hi,
I'm new to D and stumbled upon this very interesting discussion.
My question now is:
can you provide an example of how to return a collection of
homogeneous elements whose size is not known at compile time
(for
wich you would
Hi,
I'm new to D and stumbled upon this very interesting discussion.
My question now is:
can you provide an example of how to return a collection of
homogeneous elements whose size is not known at compile time (for
wich you would normally use a dynamic array) from a function?
Thanks,
Marco
On Wednesday, 17 October 2012 at 20:38:03 UTC, bearophile wrote:
Jonathan M Davis:
there's no way for the compiler to always catch it for you.<
I think there are type systems able to always catch this kind
of bug (conservative region analysis, it means that if it can't
demonstrate the memor
On 10/17/2012 10:15 PM, sclytrack wrote:
On Wednesday, 17 October 2012 at 19:46:51 UTC, bearophile wrote:
sclytrack:
It doesn't give an error when marking the function with safe.
@safe
int[] create()
{
}
I think marking it @safe is not relevant. In theory a good type system
should give an e
On Wednesday, October 17, 2012 13:07:13 Jonathan M Davis wrote:
> The only way that @safe could really be applicable would be if it became
> @system to take the address of a local variable or to slice a static array.
> And perhaps it should be, but that and catching the most obvious cases are
> all
The only way that @safe could really be applicable would be if
it became @system to take the address of a local variable or to
slice a static array. And perhaps it should be, but that and
catching the most obvious cases are all that the compiler could
do to catch this for you.
Hmmm, you coul
Jonathan M Davis:
there's no way for the compiler to always catch it for you.<
I think there are type systems able to always catch this kind of
bug (conservative region analysis, it means that if it can't
demonstrate the memory doesn't escape, it prudently refuses the
code). D doesn't have
On Wednesday, 17 October 2012 at 19:46:51 UTC, bearophile wrote:
sclytrack:
It doesn't give an error when marking the function with safe.
@safe
int[] create()
{
}
I think marking it @safe is not relevant. In theory a good type
system should give an error message on similar code. I don't
kn
On Wednesday, October 17, 2012 21:46:50 bearophile wrote:
> sclytrack:
> > It doesn't give an error when marking the function with safe.
> >
> > @safe
> > int[] create()
> > {
> > }
>
> I think marking it @safe is not relevant. In theory a good type
> system should give an error message on simila
b1 points to the exact same data as does a1. This data is stack-
allocated, and thus a2 points to an overwritten stack frame.
Thanks for explanation, I thought contetns of a1 are copied to
the heap when assignment operator executed.
sclytrack:
It doesn't give an error when marking the function with safe.
@safe
int[] create()
{
}
I think marking it @safe is not relevant. In theory a good type
system should give an error message on similar code. I don't know
if D is supposed to spot similar error situations.
Bye,
bearo
On Wednesday, 17 October 2012 at 19:22:05 UTC, Simen Kjaeraas
wrote:
On 2012-10-17, 21:17, m0rph wrote:
I tryed to learn how arrays works and found another strange
thing:
import std.stdio;
int[] create()
{
int[5] a1 = [ 10, 20, 30, 40, 50 ];
int[] b1 = a1;
writeln("b1
On 2012-10-17, 21:17, m0rph wrote:
I tryed to learn how arrays works and found another strange thing:
import std.stdio;
int[] create()
{
int[5] a1 = [ 10, 20, 30, 40, 50 ];
int[] b1 = a1;
writeln("b1: ", b1);
return b1;
}
void main()
{
int[] a2 = create
I tryed to learn how arrays works and found another strange thing:
import std.stdio;
int[] create()
{
int[5] a1 = [ 10, 20, 30, 40, 50 ];
int[] b1 = a1;
writeln("b1: ", b1);
return b1;
}
void main()
{
int[] a2 = create();
writeln("a2: ", a2);
}
R
22 matches
Mail list logo