Re: CTFE, string mixins & code generation

2020-01-24 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 24 January 2020 at 16:21:48 UTC, Jan Hönig wrote: I am looking for a detailed explanation or showcase regarding CTFE and string mixins. I want to play with D a little bit regarding code generation. I would like to have a pseudo-AST, consisting of a few classes, to represent some

Re: CTFE, string mixins & code generation

2020-01-24 Thread Jan Hönig via Digitalmars-d-learn
On Friday, 24 January 2020 at 18:43:14 UTC, H. S. Teoh wrote: CTFE in general cannot use global variables. Any state you need must be created inside a CTFE function, and accessed from within that calling context. You *can* assign values produced by CTFE to compile-time symbols via 'enum',

Re: CTFE, string mixins & code generation

2020-01-24 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 24, 2020 at 08:26:50PM +0100, Jacob Carlborg via Digitalmars-d-learn wrote: > On 2020-01-24 19:43, H. S. Teoh wrote: > > > (enums cannot take AA's or class objects as values, also, once > > assigned they are immutable). > > AA enums work. Ah you're right, it's

Re: CTFE, string mixins & code generation

2020-01-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-01-24 19:43, H. S. Teoh wrote: (enums cannot take AA's or class objects as values, also, once assigned they are immutable). AA enums work. Class objects kind of work. One can use static const/immutable instead. The following snippet compiles: class A { int a = 3; } const bar =

Re: CTFE, string mixins & code generation

2020-01-24 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 24, 2020 at 04:21:48PM +, Jan Hönig via Digitalmars-d-learn wrote: > I am looking for a detailed explanation or showcase regarding CTFE and > string mixins. > I want to play with D a little bit regarding code generation. > I would like to have a pseudo-AST, consisting of a few

Re: CTFE, string mixins & code generation

2020-01-24 Thread Jan Hönig via Digitalmars-d-learn
On Friday, 24 January 2020 at 16:59:53 UTC, Marco de Wild wrote: For CTFE: functions should be pure. Therefore you cannot use global or static variables. Constants (enums) are perfectly fine to use though. I don't know the state of the GC and CTFE. I recall that there might be some complexity

Re: CTFE, string mixins & code generation

2020-01-24 Thread Marco de Wild via Digitalmars-d-learn
On Friday, 24 January 2020 at 16:21:48 UTC, Jan Hönig wrote: I am looking for a detailed explanation or showcase regarding CTFE and string mixins. I want to play with D a little bit regarding code generation. I would like to have a pseudo-AST, consisting of a few classes, to represent some

CTFE, string mixins & code generation

2020-01-24 Thread Jan Hönig via Digitalmars-d-learn
I am looking for a detailed explanation or showcase regarding CTFE and string mixins. I want to play with D a little bit regarding code generation. I would like to have a pseudo-AST, consisting of a few classes, to represent some calculation. Think of a loop, some statements, and expressions.

Re: Call of C function breaks memoty layout

2020-01-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/24/20 9:58 AM, drug wrote: On 1/24/20 4:37 PM, Andrey wrote: Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring

Re: Call of C function breaks memoty layout

2020-01-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/24/20 8:37 AM, Andrey wrote: Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I

Re: Call of C function breaks memoty layout

2020-01-24 Thread drug via Digitalmars-d-learn
On 1/24/20 4:37 PM, Andrey wrote: Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I

Re: Call of C function breaks memoty layout

2020-01-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/24/20 8:37 AM, Andrey wrote: Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I

Re: list of all defined items in a D file

2020-01-24 Thread berni44 via Digitalmars-d-learn
On Friday, 24 January 2020 at 12:22:49 UTC, Dennis wrote: You can pass the -X flag to dmd, which makes it generate a .json file describing the compiled file. Great, that's what I was looking for - although it's also good to know the __traits approach! Thanks!

Call of C function breaks memoty layout

2020-01-24 Thread Andrey via Digitalmars-d-learn
Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I don't know why it is happens. If I

Re: list of all defined items in a D file

2020-01-24 Thread Dennis via Digitalmars-d-learn
On Thursday, 23 January 2020 at 17:10:29 UTC, berni44 wrote: I'd like to get a list of all items (public, package, private) that are defined in a D file. Is there a simple way, to get them? You can pass the -X flag to dmd, which makes it generate a .json file describing the compiled file.

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2020-01-24 Thread james bennettt via Digitalmars-d-learn
On Saturday, 16 December 2017 at 20:51:09 UTC, kerdemdemir wrote: While calling this function : bool PublicMarketCall( ref Json result ) { string fullUrl = "https://www.delta.exchange/futures-guide-bitcoin;; Json data; try { requestHTTP(fullUrl, (scope req) {