Re: question about bitfields to decode websocket header

2018-11-07 Thread lithium iodate via Digitalmars-d-learn
On Wednesday, 7 November 2018 at 13:05:49 UTC, test wrote: I am confused about the bitfields order. mixin(bitfields!( bool, "fin",1, bool, "rsv1", 1, bool, "rsv2", 1, bool, "rsv3", 1, Opcode, "opcode", 4,

question about bitfields to decode websocket header

2018-11-07 Thread test via Digitalmars-d-learn
I am confused about the bitfields order. mixin(bitfields!( bool, "fin",1, bool, "rsv1", 1, bool, "rsv2", 1, bool, "rsv3", 1, Opcode, "opcode", 4, bool, "mask", 1, ubyte,

Re: Noob question about structs allocation

2018-10-15 Thread Mike Parker via Digitalmars-d-learn
On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote: What is the effect of calling destroy? - calling the destructor? - deallocating the memory? - both? It calls the destructor. The GC will deallocate the object's memory later. However, you need to be careful about how you use

Re: Noob question about structs allocation

2018-10-15 Thread Laurent Tréguier via Digitalmars-d-learn
On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote: What is the effect of calling destroy? - calling the destructor? - deallocating the memory? - both? IIRC, it only calls the destructor, the GC will decide when to deallocate the memory.

Re: Noob question about structs allocation

2018-10-14 Thread IM via Digitalmars-d-learn
On Monday, 15 October 2018 at 03:33:04 UTC, Basile B. wrote: On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote: I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would

Re: Noob question about structs allocation

2018-10-14 Thread Basile B. via Digitalmars-d-learn
On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote: I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocating an instance on the heap using: S* s = new S; use the GC

Noob question about structs allocation

2018-10-14 Thread IM via Digitalmars-d-learn
I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocating an instance on the heap using: S* s = new S; use the GC, or do we have to call destroy() or delete on s

Re: Question about template argument matching with alias this

2018-07-30 Thread Alex via Digitalmars-d-learn
: T))´ in this case... As otherwise the restriction is to use classes only... (?) So I am back to my question: Why do we have this strange behavior? All compiler version on run.dlang.io behave like that, so I suppose there is some reason for this...?

Re: Question about template argument matching with alias this

2018-07-29 Thread Johannes Loher via Digitalmars-d-learn
back to my question: Why do we have this strange behavior? All compiler version on run.dlang.io behave like that, so I suppose there is some reason for this...? [0] https://github.com/mbierlee/poodinis [1] https://github.com/atilaneves/unit-threaded

Re: Question about template argument matching with alias this

2018-07-29 Thread Alex via Digitalmars-d-learn
On Sunday, 29 July 2018 at 16:43:08 UTC, Johannes Loher wrote: I have a question about template argument matching in combination with implicit conversion and alias this. Consider the following code: interface SomeInterface { } class SomeClass : SomeInterface { } struct SomeStruct

Question about template argument matching with alias this

2018-07-29 Thread Johannes Loher via Digitalmars-d-learn
I have a question about template argument matching in combination with implicit conversion and alias this. Consider the following code: interface SomeInterface { } class SomeClass : SomeInterface { } struct SomeStruct { SomeClass someClass; alias someClass this; } template

Re: BetterC and TypeInfo Question

2018-07-10 Thread ARaspiK via Digitalmars-d-learn
On Friday, 23 June 2017 at 04:03:04 UTC, Adam D. Ruppe wrote: On Friday, 23 June 2017 at 02:49:27 UTC, Mike wrote: My approaches are right now for -betterC to be a filthy hack to get it working quick, and I still have a bunch of ways I want to improve the implementation and compiler interface

Re: question about keeeping reference to toStringz()

2018-05-31 Thread bauss via Digitalmars-d-learn
On Thursday, 31 May 2018 at 02:10:53 UTC, Mike Parker wrote: On Thursday, 31 May 2018 at 01:12:34 UTC, Dr.No wrote: is foo() is being called from a thread, how I am supposed to keep cstring "alive"? As Jonathan explained, you don't have to worry about it if foo() itself doesn't assign the

Re: question about keeeping reference to toStringz()

2018-05-30 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 31 May 2018 at 01:12:34 UTC, Dr.No wrote: is foo() is being called from a thread, how I am supposed to keep cstring "alive"? As Jonathan explained, you don't have to worry about it if foo() itself doesn't assign the pointer to anything internally. That will be the case for

Re: question about keeeping reference to toStringz()

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 31, 2018 01:12:34 Dr.No via Digitalmars-d-learn wrote: > On Wednesday, 30 May 2018 at 20:43:48 UTC, Ali Çehreli wrote: > > On 05/30/2018 01:09 PM, Dr.No wrote: > > > consider a C function with this prototype: > > >> void foo(const char *baa); > > > > > > Does it means I should do:

Re: question about keeeping reference to toStringz()

2018-05-30 Thread Dr.No via Digitalmars-d-learn
On Wednesday, 30 May 2018 at 20:43:48 UTC, Ali Çehreli wrote: On 05/30/2018 01:09 PM, Dr.No wrote: > consider a C function with this prototype: >> void foo(const char *baa); > > Does it means I should do: > >> string s = ...; >> auto cstring = s.toStringz; >> foo(cstring); > > rather just: > >>

Re: question about keeeping reference to toStringz()

2018-05-30 Thread Ali Çehreli via Digitalmars-d-learn
On 05/30/2018 01:09 PM, Dr.No wrote: > consider a C function with this prototype: >> void foo(const char *baa); > > Does it means I should do: > >> string s = ...; >> auto cstring = s.toStringz; >> foo(cstring); > > rather just: > >> foo(s.toStringz); > > ? It depends. cstring method above is

question about keeeping reference to toStringz()

2018-05-30 Thread Dr.No via Digitalmars-d-learn
The documentation says: Important Note: When passing a char* to a C function, and the C function keeps it around for any reason, make sure that you keep a reference to it in your D code. Otherwise, it may become invalid during a garbage collection cycle and cause a nasty bug when the C code

Re: signbit question

2018-03-16 Thread Seb via Digitalmars-d-learn
On Friday, 16 March 2018 at 08:35:58 UTC, Radu wrote: On Friday, 16 March 2018 at 07:00:36 UTC, ashit axar wrote: On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); }

Re: signbit question

2018-03-16 Thread Radu via Digitalmars-d-learn
On Friday, 16 March 2018 at 07:00:36 UTC, ashit axar wrote: On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); } this generate error for dmd there. `writeln` is not

Re: signbit question

2018-03-16 Thread ashit axar via Digitalmars-d-learn
On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); } this generate error for dmd there.

Re: signbit question

2018-03-15 Thread ketmar via Digitalmars-d-learn
Miguel L wrote: as the calculations on f guarantee it cannot be 0 at all. than `f` will become zero very soon. something that "cannot happen" is the most probable thing to happen. otherwise, LGTM.

Re: signbit question

2018-03-15 Thread Dlang User via Digitalmars-d-learn
: [...] integers don't have a sign-bit. since they are not necessarily singed. However if an integer is signed and using 1-complement you can either do sign = var < 0 or sign = (var & (1 << (sizeof(var)*8 - 1)); though I cannot tell which one is faster you have to experiment. Thanks. Just one

Re: signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
they are not necessarily singed. However if an integer is signed and using 1-complement you can either do sign = var < 0 or sign = (var & (1 << (sizeof(var)*8 - 1)); though I cannot tell which one is faster you have to experiment. Thanks. Just one more question: Is this code correct? I don

Re: signbit question

2018-03-15 Thread rumbu via Digitalmars-d-learn
sizeof(var)*8 - 1)); though I cannot tell which one is faster you have to experiment. Thanks. Just one more question: Is this code correct? I don't care about +0 or -0 as the calculations on f guarantee it cannot be 0 at all. int a; float f; if((a<0)==signbit(f)) {} els

Re: signbit question

2018-03-15 Thread Seb via Digitalmars-d-learn
On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the

Re: signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
ster you have to experiment. Thanks. Just one more question: Is this code correct? I don't care about +0 or -0 as the calculations on f guarantee it cannot be 0 at all. int a; float f; if((a<0)==signbit(f)) {} else {...}

Re: signbit question

2018-03-15 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the sign of an integer? Thanks in advance integers don't have a

Re: signbit question

2018-03-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Integers are stored in an entirely different way, twos-complement instead of having a sign bit. You probably shouldn't be using the sign bit function at all, it is for

Re: signbit question

2018-03-15 Thread Seb via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? I guess because for integers you don't need to distinguish between +0.0 and -0.0, so no one bother until now to add it to

signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the sign of an integer? Thanks in advance

Re: inout question

2018-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/18 12:33 AM, Norm wrote: Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) {     import core.stdc.stdlib;     auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod (scope inout(char)* nptr, scope inout(char)**

Re: inout question

2018-02-12 Thread ketmar via Digitalmars-d-learn
lobo wrote: sure, i meant that you have to modify the second parameter accordingly. ;-) anyway, it's good that you fixed it.

Re: inout question

2018-02-12 Thread lobo via Digitalmars-d-learn
On Monday, 12 February 2018 at 05:37:23 UTC, ketmar wrote: Norm wrote: Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) { import core.stdc.stdlib; auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod

Re: inout question

2018-02-12 Thread Kagamin via Digitalmars-d-learn
On Monday, 12 February 2018 at 05:33:16 UTC, Norm wrote: I thought inout was supposed to take const or non-const variants, so expected the original const char* s to work. The problem is in argument e: it's mutable, and strtod stores there a part of s, if s is const you end up with const data

Re: inout question

2018-02-11 Thread ketmar via Digitalmars-d-learn
Norm wrote: Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) { import core.stdc.stdlib; auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod (scope inout(char)* nptr, scope inout(char)** endptr) is not

inout question

2018-02-11 Thread Norm via Digitalmars-d-learn
Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) { import core.stdc.stdlib; auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod (scope inout(char)* nptr, scope inout(char)** endptr) is not callable using

Re: Question about std.conv.parse

2018-01-30 Thread Jacky via Digitalmars-d-learn
On Tuesday, 30 January 2018 at 09:29:22 UTC, Jonathan M Davis wrote: On Tuesday, January 30, 2018 09:19:22 Jacky via Digitalmars-d-learn wrote: [...] The first one passes an lvalue. The second one passes an rvalue. parse takes its argument by ref so that what is parsed is removed from the

Re: Question about std.conv.parse

2018-01-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 30, 2018 09:19:22 Jacky via Digitalmars-d-learn wrote: > Hello everyone.I'm a newbie on the D language.When i use the > library 'std.conv' ,i met some problem. > This is what I have: > > static import std.conv; > string aaa = "123456789"; > uint idx = 5; >

Question about std.conv.parse

2018-01-30 Thread Jacky via Digitalmars-d-learn
Hello everyone.I'm a newbie on the D language.When i use the library 'std.conv' ,i met some problem. This is what I have: static import std.conv; string aaa = "123456789"; uint idx = 5; string bbb = aaa[0 .. idx]; uint work = std.conv.parse!(uint)(bbb); // this works

Re: variable template question

2018-01-14 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 14 January 2018 at 16:23:18 UTC, kdevel wrote: Why does this compile while both of the commented lines give a compile error. The code boils down to this: struct decimal32 { this(int x) {} } immutable decimal32 c = 3; /* works */ void main () { immutable decimal32 i =

variable template question

2018-01-14 Thread kdevel via Digitalmars-d-learn
vartmpl.d ``` import std.stdio : writeln; import decimal : decimal32; template F(T) { immutable T c = 3; } void foo (T) () { immutable T t = 1; } void main () { // immutable decimal32 i = 1; // Error: none of the overloads of '__ctor' are callable using a immutable object //

Re: function template specialization question D vs. C++

2018-01-14 Thread kdevel via Digitalmars-d-learn
On Sunday, 14 January 2018 at 02:24:52 UTC, Adam D. Ruppe wrote: On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis wrote: If you're using template constraints rather than template specializations, then you can't have any unconstrained templates. Not true: see the tip of the week

Re: function template specialization question D vs. C++

2018-01-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 13, 2018 19:32:06 Jonathan M Davis via Digitalmars-d- learn wrote: > On Sunday, January 14, 2018 02:24:52 Adam D. Ruppe via Digitalmars-d-learn > wrote: > > On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis > > > > wrote: > > > If you're using template constraints

Re: function template specialization question D vs. C++

2018-01-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:09:42 UTC, kdevel wrote: The compiler does not allow me to specialize the primary function template for double: Yes, it does., and it works for float and double. Just `real` matches both equally, so that's the error for that type. Let me quote the spec:

Re: function template specialization question D vs. C++

2018-01-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 14, 2018 02:24:52 Adam D. Ruppe via Digitalmars-d-learn wrote: > On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis > > wrote: > > If you're using template constraints rather than template > > specializations, then you can't have any unconstrained > > templates. > >

Re: function template specialization question D vs. C++

2018-01-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis wrote: If you're using template constraints rather than template specializations, then you can't have any unconstrained templates. Not true: see the tip of the week here http://arsdnet.net/this-week-in-d/2016-sep-04.html

Re: function template specialization question D vs. C++

2018-01-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 14, 2018 01:02:46 kdevel via Digitalmars-d-learn wrote: > On Sunday, 14 January 2018 at 00:30:37 UTC, Nicholas Wilson wrote: > > The usual way to do what you are trying to do is with template > > constraints. > > > > void foo(T)() if (is(T== float)) { ...} > > Thanks. That works

Re: function template specialization question D vs. C++

2018-01-13 Thread kdevel via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:30:37 UTC, Nicholas Wilson wrote: The usual way to do what you are trying to do is with template constraints. void foo(T)() if (is(T== float)) { ...} Thanks. That works but looks a bit ugly. Am I right that I have to leave out the primary (unconstrained)

Re: function template specialization question D vs. C++

2018-01-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:09:42 UTC, kdevel wrote: fusp.d ``` import std.stdio; import std.typecons; void foo (T) () { writeln ("(1) foo T = ", T.stringof); } void foo (T : float) () { writeln ("(2) foo T = ", T.stringof); } // void foo (T : double) () // { //writeln ("(2)

function template specialization question D vs. C++

2018-01-13 Thread kdevel via Digitalmars-d-learn
fusp.d ``` import std.stdio; import std.typecons; void foo (T) () { writeln ("(1) foo T = ", T.stringof); } void foo (T : float) () { writeln ("(2) foo T = ", T.stringof); } // void foo (T : double) () // { //writeln ("(2) foo T = ", T.stringof); // } void main () { foo!float;

Re: Question for compiler gurus about compile-time strings

2017-12-09 Thread Jonathan M Davis via Digitalmars-d-learn
t, wait, maybe that's > > only specifically for string literals. > > > > What is the true answer? If you generate a string, let's say > > via a CTFE call, does it have a null terminator? > > > > -Steve > > The results of CTFE calls are literals. Therefore

Re: Question for compiler gurus about compile-time strings

2017-12-09 Thread Stefan Koch via Digitalmars-d-learn
, let's say via a CTFE call, does it have a null terminator? -Steve The results of CTFE calls are literals. Therefore they are treated the same. Thus the answer to your question is yes. However there might be rare corner-cases in which the null termiantor is not there. Should this happen please

Question for compiler gurus about compile-time strings

2017-12-09 Thread Steven Schveighoffer via Digitalmars-d-learn
I was thinking that all strings generated at compile-time have a null-terminator added. But then I thought, wait, maybe that's only specifically for string literals. What is the true answer? If you generate a string, let's say via a CTFE call, does it have a null terminator? -Steve

Re: Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 01, 2017 03:39:12 helxi via Digitalmars-d-learn wrote: > 1. Template specialisation. > Why is this useful?: > T getResponse(T = int)(string question); And how does it differ > from > int getResponse(string question); ? > > Context: http://ddili.org/der

Re: Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 1 December 2017 at 03:39:12 UTC, helxi wrote: 1. Template specialisation. Why is this useful?: T getResponse(T = int)(string question); And how does it differ from int getResponse(string question); ? Because you can change the T at the call site. Let me give you a real world

Re: Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread user1234 via Digitalmars-d-learn
On Friday, 1 December 2017 at 03:39:12 UTC, helxi wrote: 1. Template specialisation. Why is this useful?: T getResponse(T = int)(string question); And how does it differ from int getResponse(string question); ? Good Q. Without thinking more it looks like a pointless example. The only

Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread helxi via Digitalmars-d-learn
1. Template specialisation. Why is this useful?: T getResponse(T = int)(string question); And how does it differ from int getResponse(string question); ? Context: http://ddili.org/ders/d.en/templates.html : Section: "Default template parameters" 2. "Generic locking&q

Re: Template Question

2017-11-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/19/17 2:41 PM, Adam D. Ruppe wrote: On Sunday, 19 November 2017 at 19:31:53 UTC, Jiyan wrote: Text X; You still need to instantiate it, even with default args. Text!() X; will work If that's the case, then he needs to use Text(T = char) (default type) vs. Text(T : char)

Re: Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
On Sunday, 19 November 2017 at 19:42:02 UTC, Jonathan M Davis wrote: On Sunday, November 19, 2017 19:25:40 Jiyan via Digitalmars-d-learn wrote: [...] Okay. For starters, [...] Ah ok thanks very much, this helped me a lot :)

Re: Template Question

2017-11-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 19 November 2017 at 19:31:53 UTC, Jiyan wrote: Text X; You still need to instantiate it, even with default args. Text!() X; will work

Re: Template Question

2017-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 19, 2017 19:25:40 Jiyan via Digitalmars-d-learn wrote: > With working i mean that > Text X; > Doesnt compile! Okay. For starters, struct Text(T : char) { size_t _len; T* _ptr; } is a template specialization, which means that it's only going to compile if T is char or

Re: Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
On Sunday, 19 November 2017 at 19:28:37 UTC, Jonathan M Davis wrote: On Sunday, November 19, 2017 19:22:51 Jiyan via Digitalmars-d-learn wrote: Hello, i wanted to ask why this isnt working: struct Text(T : char) { size_t _len; T* _ptr; } Thanks :) What about it isn't working? I think

Re: Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
With working i mean that Text X; Doesnt compile!

Re: Template Question

2017-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 19, 2017 19:22:51 Jiyan via Digitalmars-d-learn wrote: > Hello, > > i wanted to ask why this isnt working: > > struct Text(T : char) > { > size_t _len; > T* _ptr; > } > > Thanks :) What about it isn't working? I think that you need to explain what you're trying to do and

Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
Hello, i wanted to ask why this isnt working: struct Text(T : char) { size_t _len; T* _ptr; } Thanks :)

Re: Inline assembly question

2017-11-13 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Monday, 13 November 2017 at 18:40:42 UTC, Basile B. wrote: TBH I wonder if this is not worth a enhancement (or even a DIP) to have in asm blocks a special alias syntax... { asm { version(...) { alias First = RDI; alias Second = RSI;

Re: Inline assembly question

2017-11-13 Thread Dibyendu Majumdar via Digitalmars-d-learn
would need to do? Another question - how can I tell DMD to no generate the frame pointer? Hi, any further info on this? I am not talking here of the assembly push/pop instructions, rather the .pdata and .xdata sections needed on Win64. Thanks and Regards Dibyendu

Re: Inline assembly question

2017-11-13 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 12 November 2017 at 22:20:46 UTC, Dibyendu Majumdar no in naked mode you have to save and restore by hand. Note that in Win64 even if not naked, you'll have to save/restore some registers like XMMx with x >= 6. Another question - how can I tell DMD to no generate the fr

Re: Inline assembly question

2017-11-13 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 13 November 2017 at 18:40:42 UTC, Basile B. wrote: TBH I wonder if this is not worth a enhancement (or even a DIP) to have in asm blocks a special alias syntax... { asm { version(...) { alias First = RDI; alias Second = RSI; //

Re: Inline assembly question

2017-11-13 Thread Basile B. via Digitalmars-d-learn
On Monday, 13 November 2017 at 18:40:42 UTC, Basile B. wrote: On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar wrote: [...] TBH I wonder if this is not worth a enhancement (or even a DIP) to have in asm blocks a special alias syntax... { asm { version(...)

Re: Inline assembly question

2017-11-13 Thread Basile B. via Digitalmars-d-learn
On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar wrote: Hi, I have recently started work on building a VM for Lua (actually a derivative of Lua) in X86-64 assembly. I am using the dynasm tool that is part of LuaJIT. I was wondering whether I could also write this in D's inline

Re: Inline assembly question

2017-11-12 Thread Dibyendu Majumdar via Digitalmars-d-learn
; will DMD generate the right Win64 unwind info for this contrived example: no in naked mode you have to save and restore by hand. So how does one manually generate the .pdata and .xdata sections? Are you saying that this is what I would need to do? Another question - how can I tell DMD

Re: Inline assembly question

2017-11-12 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Sunday, 12 November 2017 at 22:00:58 UTC, Basile B. wrote: On Sunday, 12 November 2017 at 21:27:28 UTC, Dibyendu Majumdar Does the compiler generate appropriate unwind information on Win64? Prsumably if a function is marked 'naked' then it doesn't? yeah about stack frame..., also don't

Re: Inline assembly question

2017-11-12 Thread Basile B. via Digitalmars-d-learn
On Sunday, 12 November 2017 at 22:20:46 UTC, Dibyendu Majumdar wrote: On Sunday, 12 November 2017 at 22:00:58 UTC, Basile B. wrote: On Sunday, 12 November 2017 at 21:27:28 UTC, Dibyendu Majumdar I am not sure I have understood above; will DMD generate the right Win64 unwind info for this

Re: Inline assembly question

2017-11-12 Thread Basile B. via Digitalmars-d-learn
On Sunday, 12 November 2017 at 21:27:28 UTC, Dibyendu Majumdar wrote: On Sunday, 12 November 2017 at 18:48:02 UTC, Eugene Wissner wrote: https://dlang.org/spec/iasm.html#agregate_member_offsets aggregate.member.offsetof[someregister] Sorry I didn't phrase my question accurately. Presumably

Re: Inline assembly question

2017-11-12 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Sunday, 12 November 2017 at 18:48:02 UTC, Eugene Wissner wrote: https://dlang.org/spec/iasm.html#agregate_member_offsets aggregate.member.offsetof[someregister] Sorry I didn't phrase my question accurately. Presumably to use above with the mnemonics I would need additional mixin

Re: Inline assembly question

2017-11-12 Thread Eugene Wissner via Digitalmars-d-learn
PC, CI->u.l.savedpc// PC = CI->u.l.savedpc How can I mix the mixin above and combine with struct offsets? https://dlang.org/spec/iasm.html#agregate_member_offsets aggregate.member.offsetof[someregister] Sorry I didn't phrase my question accurately. Presumably t

Re: Inline assembly question

2017-11-12 Thread Dibyendu Majumdar via Digitalmars-d-learn
ow can I mix the mixin above and combine with struct offsets? https://dlang.org/spec/iasm.html#agregate_member_offsets aggregate.member.offsetof[someregister] Sorry I didn't phrase my question accurately. Presumably to use above with the mnemonics I would need additional mixin templates where t

Re: Inline assembly question

2017-11-12 Thread Basile B. via Digitalmars-d-learn
On Sunday, 12 November 2017 at 12:17:51 UTC, Dibyendu Majumdar wrote: On Sunday, 12 November 2017 at 11:55:23 UTC, Eugene Wissner wrote: [...] Thank you - I probably could use something like this. It is uglier than the simpler approach in dynasm of course. How about when I need to combine

Re: Inline assembly question

2017-11-12 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Sunday, 12 November 2017 at 11:55:23 UTC, Eugene Wissner wrote: On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar wrote: I have recently started work on building a VM for Lua (actually a derivative of Lua) in X86-64 assembly. I am using the dynasm tool that is part of LuaJIT. I

Re: Inline assembly question

2017-11-12 Thread Dibyendu Majumdar via Digitalmars-d-learn
. I see...the problem is not the input parameters but functions calls **inside** iasm, right ? Not sure I understand the question. Once the defines are there I can write following: | // Call luaF_close | mov CARG1, L // arg1 = L | mov CARG2, BASE

Re: Inline assembly question

2017-11-12 Thread Eugene Wissner via Digitalmars-d-learn
On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar wrote: Hi, I have recently started work on building a VM for Lua (actually a derivative of Lua) in X86-64 assembly. I am using the dynasm tool that is part of LuaJIT. I was wondering whether I could also write this in D's inline

Re: Inline assembly question

2017-11-12 Thread Basile B. via Digitalmars-d-learn
On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar wrote: Hi, [...] The assembly code uses static allocation of registers, but because of the differences in how registers are used in Win64 versus Unix X64 - different registers are assigned depending on the architecture. dynasm

Re: Inline assembly question

2017-11-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar wrote: Hi, I have recently started work on building a VM for Lua (actually a derivative of Lua) in X86-64 assembly. I am using the dynasm tool that is part of LuaJIT. I was wondering whether I could also write this in D's inline

Inline assembly question

2017-11-12 Thread Dibyendu Majumdar via Digitalmars-d-learn
Hi, I have recently started work on building a VM for Lua (actually a derivative of Lua) in X86-64 assembly. I am using the dynasm tool that is part of LuaJIT. I was wondering whether I could also write this in D's inline assembly perhaps, but there is one aspect that I am not sure how to

Re: Real beginner traits question

2017-09-25 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 25, 2017 at 03:41:14PM +, WhatMeWorry via Digitalmars-d-learn wrote: > On Monday, 25 September 2017 at 06:07:58 UTC, H. S. Teoh wrote: > > On Mon, Sep 25, 2017 at 05:28:13AM +, WhatMeForget via > > Digitalmars-d-learn wrote: > > > [...] > > > > You're not the only one. I

Re: Real beginner traits question

2017-09-25 Thread WhatMeWorry via Digitalmars-d-learn
On Monday, 25 September 2017 at 06:07:58 UTC, H. S. Teoh wrote: On Mon, Sep 25, 2017 at 05:28:13AM +, WhatMeForget via Digitalmars-d-learn wrote: [...] You're not the only one. I stared at this same piece of documentation for a long time before I figured out what it meant. This is

Re: Real beginner traits question

2017-09-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 25, 2017 05:28:13 WhatMeForget via Digitalmars-d-learn wrote: > This is taken exactly from the traits documentation. > > > > 25 Traits > > 25.21 identifier > > Takes one argument, a symbol. Returns the identifier for that >

Re: Real beginner traits question

2017-09-25 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 25, 2017 at 05:28:13AM +, WhatMeForget via Digitalmars-d-learn wrote: > > This is taken exactly from the traits documentation. > > > > 25 Traits > > 25.21 identifier > > Takes one argument, a symbol. Returns the identifier for

Re: Real beginner traits question

2017-09-24 Thread rikki cattermole via Digitalmars-d-learn
On 25/09/2017 6:28 AM, WhatMeForget wrote: This is taken exactly from the traits documentation. 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal.

Real beginner traits question

2017-09-24 Thread WhatMeForget via Digitalmars-d-learn
This is taken exactly from the traits documentation. 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal. There are no

Re: Basic LDC Linux Install Question

2017-09-19 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 12:37:12 UTC, Daniel Kozak wrote: Yes you need to add ldc2 to your PATH. So if your ldc2 binary is in /user/something/something/folder_where_is_ldc2/ldc2 you havto add /user/something/something/folder_where_is_ldc2 to your PATH. You can test this by pasting

Re: Basic LDC Linux Install Question

2017-09-19 Thread Daniel Kozak via Digitalmars-d-learn
Yes you need to add ldc2 to your PATH. So if your ldc2 binary is in /user/something/something/folder_where_is_ldc2/ldc2 you havto add /user/something/something/folder_where_is_ldc2 to your PATH. You can test this by pasting this to terminal: export

Basic LDC Linux Install Question

2017-09-19 Thread jmh530 via Digitalmars-d-learn
I'm more of a Windows user than a Linux user. I have the latest DMD on my Linux install (linux mint 17.3), but I wanted to test LDC. I get a message that ldc2 is not found when I type ldc2 --version or sudo ldc2 --version (I'm not on root and the existing user does not have root privileges,

Re: Question on Container Array.

2017-09-18 Thread Eugene Wissner via Digitalmars-d-learn
On Monday, 18 September 2017 at 11:47:07 UTC, Vino.B wrote: Hi All, Can some one explain me on the below question. Q1: void main (Array!string args) : Why can't we use container array in void main? Q2: What is the difference between the below? insert, insertBack stableInsert

Question on Container Array.

2017-09-18 Thread Vino.B via Digitalmars-d-learn
Hi All, Can some one explain me on the below question. Q1: void main (Array!string args) : Why can't we use container array in void main? Q2: What is the difference between the below? insert, insertBack stableInsert, stableInsertBack linearInsert, stableLinearInsert, stableLinearInsert Q3

Re: DIPs - question about mores, etiquette and DIP1009 in particular

2017-08-30 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 22:50:22 UTC, Cecil Ward wrote: On Wednesday, 30 August 2017 at 22:09:21 UTC, Mike Parker wrote: On Wednesday, 30 August 2017 at 17:16:11 UTC, Cecil Ward wrote: DIPs are not voted on. Thanks for letting me know, answers my question. Our leaders would perhaps

Re: DIPs - question about mores, etiquette and DIP1009 in particular

2017-08-30 Thread ketmar via Digitalmars-d-learn
Cecil Ward wrote: On Wednesday, 30 August 2017 at 17:19:52 UTC, ketmar wrote: it is explicitly stated in DIP that existing syntax will not be deprecated/removed. i guess that reading the DIP before expressing your opinion is the prerequisite... Good to know. A relief. I am full of pain

Re: DIPs - question about mores, etiquette and DIP1009 in particular

2017-08-30 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 22:09:21 UTC, Mike Parker wrote: On Wednesday, 30 August 2017 at 17:16:11 UTC, Cecil Ward wrote: DIPs are not voted on. Thanks for letting me know, answers my question. Our leaders would perhaps find a simple pair of numbers to be a useful additional metric

<    1   2   3   4   5   6   7   8   9   10   >