digitalmars.D - Send/Receive bug in std.concurrency with immutable(ubyte[]) ?
- Vijay Nayar (17/17) Aug 04 2019 import std.concurrency;
- Paul Backus (11/28) Aug 04 2019 immutable(T[]) "decays" to immutable(T)[] when passed to a
- Jonathan M Davis (13/50) Aug 04 2019 When you slice a const or immutable dynamic array, the type of the resul...
- GreatSam4sure (5/64) Aug 04 2019 Sorry, sir, this day your participation in this forum is very
- Jonathan M Davis (10/14) Aug 06 2019 I still participate, but I don't want it to suck up my time as it someti...
- GreatSam4sure (2/14) Aug 06 2019 Thanks, it is cool to hear from you
import std.concurrency; import std.stdio; void testThread() { receive( (immutable(ubyte[]) data) => writeln("Got it!"), (Variant v) => writeln("Mismatch: ", v.type())); } void main() { immutable(ubyte[]) data = [1, 2, 3]; auto tid = spawn(&testThread); send(tid, data); } The output of this program is: Mismatch: immutable(ubyte)[] Why does calling send with data of type immutable(ubyte[]) get converted to immutable(byte)[] when it is called with std.concurrency's send() and receive(). Is this a bug?
Aug 04 2019
On Sunday, 4 August 2019 at 13:57:14 UTC, Vijay Nayar wrote:import std.concurrency; import std.stdio; void testThread() { receive( (immutable(ubyte[]) data) => writeln("Got it!"), (Variant v) => writeln("Mismatch: ", v.type())); } void main() { immutable(ubyte[]) data = [1, 2, 3]; auto tid = spawn(&testThread); send(tid, data); } The output of this program is: Mismatch: immutable(ubyte)[] Why does calling send with data of type immutable(ubyte[]) get converted to immutable(byte)[] when it is called with std.concurrency's send() and receive(). Is this a bug?immutable(T[]) "decays" to immutable(T)[] when passed to a function (most of the time [1]): import std.stdio; void checkType(T)(T arg) { writeln(typeof(arg).stringof); } void main() { immutable(ubyte[]) a; checkType(a); // immutable(ubyte)[] } [1] https://issues.dlang.org/show_bug.cgi?id=18268
Aug 04 2019
On Sunday, August 4, 2019 8:29:05 AM MDT Paul Backus via Digitalmars-d wrote:On Sunday, 4 August 2019 at 13:57:14 UTC, Vijay Nayar wrote:When you slice a const or immutable dynamic array, the type of the resulting dynamic array is tail-const or tail-immutable. When templates are implicitly instantiated with IFTI, and a dynamic array is passed in, the type is always inferred using the type of the slice of the dynamic array. That's completely consistent. You only get a fully const or immutable dynamic array with a template when the template is explicitly instantiated with that type. However, based on the examples in that bug report, what happens with lambdas and function/delegate literals is not consistent - or at least, the reasons why the type inference uses the type of the slice in some cases and the type of the array being sliced in others isn't immediately clear. - Jonathan M Davisimport std.concurrency; import std.stdio; void testThread() { receive( (immutable(ubyte[]) data) => writeln("Got it!"), (Variant v) => writeln("Mismatch: ", v.type())); } void main() { immutable(ubyte[]) data = [1, 2, 3]; auto tid = spawn(&testThread); send(tid, data); } The output of this program is: Mismatch: immutable(ubyte)[] Why does calling send with data of type immutable(ubyte[]) get converted to immutable(byte)[] when it is called with std.concurrency's send() and receive(). Is this a bug?immutable(T[]) "decays" to immutable(T)[] when passed to a function (most of the time [1]): import std.stdio; void checkType(T)(T arg) { writeln(typeof(arg).stringof); } void main() { immutable(ubyte[]) a; checkType(a); // immutable(ubyte)[] } [1] https://issues.dlang.org/show_bug.cgi?id=18268
Aug 04 2019
On Sunday, 4 August 2019 at 15:19:49 UTC, Jonathan M Davis wrote:On Sunday, August 4, 2019 8:29:05 AM MDT Paul Backus via Digitalmars-d wrote:Sorry, sir, this day your participation in this forum is very limited. Is it due to work load? I really want to know. You can reach me personally with this mail: greatsam4sure gmail.com Sorry sir, is just that I don't know how else to reach you.On Sunday, 4 August 2019 at 13:57:14 UTC, Vijay Nayar wrote:When you slice a const or immutable dynamic array, the type of the resulting dynamic array is tail-const or tail-immutable. When templates are implicitly instantiated with IFTI, and a dynamic array is passed in, the type is always inferred using the type of the slice of the dynamic array. That's completely consistent. You only get a fully const or immutable dynamic array with a template when the template is explicitly instantiated with that type. However, based on the examples in that bug report, what happens with lambdas and function/delegate literals is not consistent - or at least, the reasons why the type inference uses the type of the slice in some cases and the type of the array being sliced in others isn't immediately clear. - Jonathan M Davisimport std.concurrency; import std.stdio; void testThread() { receive( (immutable(ubyte[]) data) => writeln("Got it!"), (Variant v) => writeln("Mismatch: ", v.type())); } void main() { immutable(ubyte[]) data = [1, 2, 3]; auto tid = spawn(&testThread); send(tid, data); } The output of this program is: Mismatch: immutable(ubyte)[] Why does calling send with data of type immutable(ubyte[]) get converted to immutable(byte)[] when it is called with std.concurrency's send() and receive(). Is this a bug?immutable(T[]) "decays" to immutable(T)[] when passed to a function (most of the time [1]): import std.stdio; void checkType(T)(T arg) { writeln(typeof(arg).stringof); } void main() { immutable(ubyte[]) a; checkType(a); // immutable(ubyte)[] } [1] https://issues.dlang.org/show_bug.cgi?id=18268
Aug 04 2019
On Sunday, August 4, 2019 12:30:37 PM MDT GreatSam4sure via Digitalmars-d wrote:Sorry, sir, this day your participation in this forum is very limited. Is it due to work load? I really want to know. You can reach me personally with this mail: greatsam4sure gmail.com Sorry sir, is just that I don't know how else to reach you.I still participate, but I don't want it to suck up my time as it sometimes has. A combination of some health issues and trying to focus on work have reduced how much time I've been spending on D in general outside of work, though I do need to figure out how to spend some more time contributing. If you wish to contact me about something, the about page on my website provides my e-mail address: http://jmdavisprog.com/about.html - Jonathan M Davis
Aug 06 2019
On Tuesday, 6 August 2019 at 10:27:49 UTC, Jonathan M Davis wrote:On Sunday, August 4, 2019 12:30:37 PM MDT GreatSam4sure via Digitalmars-d wrote:Thanks, it is cool to hear from you[...]I still participate, but I don't want it to suck up my time as it sometimes has. A combination of some health issues and trying to focus on work have reduced how much time I've been spending on D in general outside of work, though I do need to figure out how to spend some more time contributing. If you wish to contact me about something, the about page on my website provides my e-mail address: http://jmdavisprog.com/about.html - Jonathan M Davis
Aug 06 2019