import std.stdio;
union EarthLocation
{
struct { immutable double lon, lat, alt; }
double[3] data;
}
void main()
{
EarthLocation d = {data: [4, 5, 6]};
writeln(d.data);
d.data = [1, 2, 3];
writeln(d.data);
}
I get the output:
[4, 5, 6]
[1, 2, 3]
I thought the promise of
On Saturday, 2 January 2016 at 12:07:31 UTC, John Colvin wrote:
You are manually breaking immutable by making a union of
immutable and mutable data and then writing to the mutable
reference. This is roughly equivalent to casting away immutable
and then writing to the reference. It's a bug in
On Saturday, 2 January 2016 at 10:04:47 UTC, Shriramana Sharma
wrote:
import std.stdio;
union EarthLocation
{
struct { immutable double lon, lat, alt; }
double[3] data;
}
void main()
{
EarthLocation d = {data: [4, 5, 6]};
writeln(d.data);
d.data = [1, 2, 3];
On Saturday, 2 January 2016 at 12:08:48 UTC, Meta wrote:
On Saturday, 2 January 2016 at 12:07:31 UTC, John Colvin wrote:
You are manually breaking immutable by making a union of
immutable and mutable data and then writing to the mutable
reference. This is roughly equivalent to casting away
On 01/02/2016 12:32 AM, TheDGuy wrote:
On Friday, 1 January 2016 at 22:00:04 UTC, TheDGuy wrote:
On Friday, 1 January 2016 at 19:32:40 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:
Hello,
On Saturday, 2 January 2016 at 12:08:48 UTC, Meta wrote:
On Saturday, 2 January 2016 at 12:07:31 UTC, John Colvin wrote:
You are manually breaking immutable by making a union of
immutable and mutable data and then writing to the mutable
reference. This is roughly equivalent to casting away
On Saturday, 2 January 2016 at 02:12:19 UTC, Shriramana Sharma
wrote:
If I have:
struct TimeSpan { double start, end; }
Then both the following automatically work:
auto s = TimeSpan();
auto t = TimeSpan(1, 2);
But if I make it a class (I need to) then I have to explicitly
define a
On Saturday, 2 January 2016 at 01:44:46 UTC, Adam D. Ruppe wrote:
On Saturday, 2 January 2016 at 00:32:20 UTC, alkololl wrote:
Why is that?
I'm not sure, but in the switch you posted, you didn't handle
the DLL_THREAD_ATTACH and DLL_THREAD_DETACH cases, the runtime
might be incrementing the
On Saturday, 2 January 2016 at 14:57:58 UTC, Shriramana Sharma
wrote:
John Colvin wrote:
Strictly speaking you aren't calling a constructor there,
you're writing a struct literal.
Why do you say I'm not calling a constructor?
https://dlang.org/spec/struct.html#struct-literal
And that
On Saturday, 2 January 2016 at 16:48:41 UTC, Jack wrote:
So yeah I've been trying to experiment with the language when
I'm met with an Access Violation error.
So I've extracted a string from a file and used it as an index
for a dynamic array. Stripped code sample is :
On Friday, 1 January 2016 at 12:29:01 UTC, anonymous wrote:
On 30.12.2015 12:06, Ivan Kazmenko wrote:
As you can see, bmatch (usage discouraged in the docs) gives
me the
result I want, but match (also discouraged) and matchAll (way
to go) don't.
Am I misusing matchAll, or is this a bug?
On Saturday, 2 January 2016 at 16:42:46 UTC, Rainer Schuetze
wrote:
On 02.01.2016 16:34, alkololl wrote:
On Saturday, 2 January 2016 at 01:44:46 UTC, Adam D. Ruppe
wrote:
[...]
Thanks for your reply. I replaced my switch statement with the
one
behind the link you left but the result (no
John Colvin wrote:
> Casting away immutable can sometimes be necessary (e.g. when
> talking to other languages), so I'm not sure it should be
> disallowed, but it'd be great if it was somehow easier to catch
> these bugs.
Yes it was in the context of talking to C that I needed to make such a
John Colvin wrote:
> Strictly speaking you aren't calling a constructor there, you're
> writing a struct literal.
Why do you say I'm not calling a constructor?
And that still doesn't answer the question of why can't we have an automatic
field-wise constructor for classes...
--
Shriramana
On Saturday, 2 January 2016 at 16:48:41 UTC, Jack wrote:
[...]
Also, your sample reads from an external file, "read.txt". Either
give us the contents of that file, or change the sample so that
it is not required.
On Saturday, 2 January 2016 at 17:15:53 UTC, tsbockman wrote:
On Saturday, 2 January 2016 at 16:48:41 UTC, Jack wrote:
[...]
Also, your sample reads from an external file, "read.txt".
Either give us the contents of that file, or change the sample
so that it is not required.
Woops, sorry
On Saturday, 2 January 2016 at 17:56:12 UTC, tsbockman wrote:
On Saturday, 2 January 2016 at 17:39:42 UTC, Jack wrote:
[...]
By far the most likely explanation for an exception at that
location, would be if `custom_keyword` really didn't contain a
valid key into the `custom` associative
So yeah I've been trying to experiment with the language when I'm
met with an Access Violation error.
So I've extracted a string from a file and used it as an index
for a dynamic array. Stripped code sample is :
/
void foo()
{
string[string] custom;
string
On Saturday, 2 January 2016 at 10:04:47 UTC, Shriramana Sharma
wrote:
I thought the promise of `immutable` was: never changes.
The compiler doesn't protect you by carrying a bomb. :)
But there is another usecase where it makes sense to allow
writing to other union members despite the
```
import cairo.ImageSurface;
ImageSurface.createForData(c,cairo.FORMAT_ARGB32,256,256,256*4);
```
You need to import the ImageSurface module, and the
createForData function is in the ImageSurface class which is in
the cairo.ImageSurface module.
Thanks, that was the problem!
Now i can read
On Saturday, 2 January 2016 at 17:39:42 UTC, Jack wrote:
So I'll just send the whole file if you don't mind:
http://dpaste.com/11V5BYA (Line 174-183)
The contents of the .txt file is :
http://dpaste.com/3FVW5QR
I didn't put a lot of effort into trying to actually understand
what you're
On Saturday, 2 January 2016 at 13:15:37 UTC, John Colvin wrote:
Casting away immutable can sometimes be necessary (e.g. when
talking to other languages), so I'm not sure it should be
disallowed, but it'd be great if it was somehow easier to catch
these bugs.
It should be disallowed in @safe
On 02.01.2016 16:34, alkololl wrote:
On Saturday, 2 January 2016 at 01:44:46 UTC, Adam D. Ruppe wrote:
On Saturday, 2 January 2016 at 00:32:20 UTC, alkololl wrote:
Why is that?
I'm not sure, but in the switch you posted, you didn't handle the
DLL_THREAD_ATTACH and DLL_THREAD_DETACH cases,
On Saturday, 2 January 2016 at 14:57:58 UTC, Shriramana Sharma
wrote:
John Colvin wrote:
Strictly speaking you aren't calling a constructor there,
you're writing a struct literal.
Why do you say I'm not calling a constructor?
A class constructor is written as:
auto s = *new* Timespan(1,
On Saturday, 2 January 2016 at 17:39:42 UTC, Jack wrote:
So I'll just send the whole file if you don't mind:
http://dpaste.com/11V5BYA (Line 174-183)
The contents of the .txt file is :
http://dpaste.com/3FVW5QR
I just checked it and it compiles but it does that strange
Access Violation
On Saturday, 2 January 2016 at 18:14:24 UTC, tsbockman wrote:
On Saturday, 2 January 2016 at 17:39:42 UTC, Jack wrote:
So I'll just send the whole file if you don't mind:
http://dpaste.com/11V5BYA (Line 174-183)
The contents of the .txt file is :
http://dpaste.com/3FVW5QR
I didn't put a lot
I have a rather large header file used to write plugins for
reaper:
http://pastebin.com/Eebv1e0M
This file, unfortunately may change quite often depending on the
version of reaper. Reaper automatically generates the C++ file.
Is there a way to automatically convert this without too much
On 03/01/16 7:04 PM, Arialis Majoris wrote:
I have a rather large header file used to write plugins for reaper:
http://pastebin.com/Eebv1e0M
This file, unfortunately may change quite often depending on the version
of reaper. Reaper automatically generates the C++ file. Is there a way
to
28 matches
Mail list logo