Re: prolog and epilog code

2016-08-02 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 20:28:51 UTC, Rufus Smith wrote: On Tuesday, 2 August 2016 at 18:34:49 UTC, Steven Schveighoffer wrote: On 8/2/16 2:25 PM, Rufus Smith wrote: So, something funky is going on. Any ideas? phobos is not being resolved. I don't use visualD, so I'm not sure what the

Re: [OT] Create more debt == earn more

2016-08-02 Thread Rufus Smith via Digitalmars-d
On Tuesday, 2 August 2016 at 08:07:38 UTC, Basile B. wrote: I was thinking about the value of what we do in the life, daily, the jobs, etc I've endend with this conclusion: The more you're able to create debt, the more you'll earn. example, CIO: hudge pay, because your 1000 salaries will

Re: prolog and epilog code

2016-08-02 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 18:34:49 UTC, Steven Schveighoffer wrote: On 8/2/16 2:25 PM, Rufus Smith wrote: So, something funky is going on. Any ideas? phobos is not being resolved. I don't use visualD, so I'm not sure what the issue is, it's probably a compiler or linker ordering issue.

Re: prolog and epilog code

2016-08-02 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 17:25:21 UTC, Steven Schveighoffer wrote: On 8/2/16 1:04 PM, Rufus Smith wrote: On Tuesday, 2 August 2016 at 16:30:08 UTC, Adam D. Ruppe wrote: On Tuesday, 2 August 2016 at 16:21:07 UTC, Rufus Smith wrote: How does one use C main? extern C? extern(C) int main()

Re: prolog and epilog code

2016-08-02 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 16:30:08 UTC, Adam D. Ruppe wrote: On Tuesday, 2 August 2016 at 16:21:07 UTC, Rufus Smith wrote: How does one use C main? extern C? extern(C) int main() should do it It doesn't seem to be that easy! https://wiki.dlang.org/Runtime_internals If I do this then I

Re: prolog and epilog code

2016-08-02 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 11:37:05 UTC, Steven Schveighoffer wrote: On 8/1/16 9:24 PM, Rufus Smith wrote: Can one add code that executes before the GC and any memory is normally allocated(even static) and after all of it was suppose to be released? Of course! You just have to modify

prolog and epilog code

2016-08-01 Thread Rufus Smith via Digitalmars-d-learn
Can one add code that executes before the GC and any memory is normally allocated(even static) and after all of it was suppose to be released? A sort of static this for the whole app. I would like to monitor the memory of the app to make sure that the total memory before and after is equal.

Re: Cannot compare object.opEquals is not nogc

2016-07-31 Thread Rufus Smith via Digitalmars-d-learn
On Monday, 25 July 2016 at 12:24:53 UTC, Steven Schveighoffer wrote: On 7/23/16 5:44 PM, Rufus Smith wrote: [...] Again, I want to stress that Object.opEquals has been around since early D1 days, @nogc is only a few years old, it was not a wrong decision. @nogc cannot be added without

Re: Cannot compare object.opEquals is not nogc

2016-07-31 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals' Shouldn't object opEquals be marked? So, I need to compare two

Re: Modules

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
NM, ignore. Seems it was something else going on. Although, if you know how how dmd resolves this stuff exactly, it would be nice to know. Does it just use the module names regardless of path or does the path where the module is located have any play(assuming they are properly passed to the

Modules

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
How do module names and actual folder paths relate? For my own libraries, I use the file path as module name, more or less. e.g., module foo.bar.x; is in folder foo\bar. I imported some external lib that has it's own layout, but I wanted to incorporate it in to my lib, so I stuck it in a

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 22:48:07 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 21:44:05 UTC, Rufus Smith wrote: On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: - we trust what we are doing: e.g. we cannot mark a thing @nogc, but we know it is and the

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 17:04:42 UTC, Jonathan Marler wrote: On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:23:37 UTC, Marco Leise wrote: Am Sat, 23 Jul 2016 13:18:03 + schrieb Rufus Smith : Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals'

Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals' Shouldn't object opEquals be marked?

Re: Building phobos GDC

2016-07-22 Thread Rufus Smith via Digitalmars-d-learn
On Friday, 22 July 2016 at 19:52:59 UTC, Lodovico Giaretta wrote: On Friday, 22 July 2016 at 18:30:13 UTC, Rufus Smith wrote: Trying to compile code that uses GDC, had to import phobos files from dmd in to project since they are not in the GDC's phobo lib(the core.sys.windows stuff). Almost

Building phobos GDC

2016-07-22 Thread Rufus Smith via Digitalmars-d-learn
Trying to compile code that uses GDC, had to import phobos files from dmd in to project since they are not in the GDC's phobo lib(the core.sys.windows stuff). Almost all the errors are related to stuff like PALETTEENTRY* peNew() return { return _peNew.ptr; } Does that even make sense?

Re: union initalization

2016-07-21 Thread Rufus Smith via Digitalmars-d-learn
On Friday, 22 July 2016 at 02:08:06 UTC, Ali Çehreli wrote: On 07/21/2016 06:48 PM, Rufus Smith wrote: > I would like to combine two types > > > template Foo(A, B = 4) > { > union > { > byte b = B; > int a = A << 8; > } > } > > This packs a and b together in to an

union initalization

2016-07-21 Thread Rufus Smith via Digitalmars-d-learn
I would like to combine two types template Foo(A, B = 4) { union { byte b = B; int a = A << 8; } } This packs a and b together in to an int bytes, saving an int(rather than storing a and b in an int each) and makes it easier to access. I get an error about

Dynamic code generation

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
Does D offer any solutions to generate code dynamically? I would like to order based on optimal strategies. This requires effectively hard coding the execution path. A simple example, if (x == true) foo(); else bar(); can be recoded to be foo() or bar() while x is fixed, in my case x

Re: Template arguments produce unidentified identifier

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 01:48:31 UTC, Adam D. Ruppe wrote: Take a read of this: http://stackoverflow.com/a/32621854/1457000 The short of it is don't mixin stringof. Instead, mixin the actual template itself. The functionLinkage might need to be string, but the types should remain

Re: Template arguments produce unidentified identifier

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
If it's not clear, I have to import the proper identifiers but every use of the template would require the user to add their import. Obviously not the way to go.

Template arguments produce unidentified identifier

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
I have complex template that uses a mixin to solve some problems. The mixin produces the error. I thought template's were added in to the scope of the call? I guess the mixin is inserted before this happens. That isn't good ;/ Here is one place the error happens mixin("alias Func =

Re: Allowing "fall through" of attributes

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 19 July 2016 at 17:10:35 UTC, Lodovico Giaretta wrote: On Tuesday, 19 July 2016 at 17:05:55 UTC, Rufus Smith wrote: On Tuesday, 19 July 2016 at 16:59:48 UTC, Lodovico Giaretta wrote: On Tuesday, 19 July 2016 at 16:50:56 UTC, Rufus Smith wrote: On Tuesday, 19 July 2016 at 16:09:38

Re: Allowing "fall through" of attributes

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 19 July 2016 at 16:59:48 UTC, Lodovico Giaretta wrote: On Tuesday, 19 July 2016 at 16:50:56 UTC, Rufus Smith wrote: On Tuesday, 19 July 2016 at 16:09:38 UTC, Lodovico Giaretta wrote: [...] But this doesn't create a function with all the attributes of the original? Just one that

Re: How to get the "this" ptr of a lambda inside the lambda?

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 19 July 2016 at 16:58:12 UTC, Steven Schveighoffer wrote: On 7/19/16 12:52 PM, Rufus Smith wrote: On Tuesday, 19 July 2016 at 15:58:49 UTC, Steven Schveighoffer wrote: [...] Yes, but then this = null. I matters not for my use case. 'this' is not null in either case. There is no

Re: How to get the "this" ptr of a lambda inside the lambda?

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 19 July 2016 at 15:58:49 UTC, Steven Schveighoffer wrote: On 7/19/16 11:25 AM, Rufus Smith wrote: [...] I think what Mike may be alluding to is that there is no name for the stack frame pointer you can use. There is no 'this' pointer that you can get at (even though it can be

Re: Allowing "fall through" of attributes

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 19 July 2016 at 16:09:38 UTC, Lodovico Giaretta wrote: On Tuesday, 19 July 2016 at 15:55:02 UTC, Rufus Smith wrote: I have some functions that take other functions. I would like the attributes to be able to "fall" through so I get overload like behavior. I only care that I am

Allowing "fall through" of attributes

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
I have some functions that take other functions. I would like the attributes to be able to "fall" through so I get overload like behavior. I only care that I am passing a function, not if it is shared, extern(C), pure, @nogc, etc. void foo(R, A...)(R function(A) bar) { alias type =

Re: How to get the "this" ptr of a lambda inside the lambda?

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Tuesday, 19 July 2016 at 06:46:44 UTC, Mike Parker wrote: On Tuesday, 19 July 2016 at 06:32:32 UTC, Rufus Smith wrote: Error: 'this' is only defined in non-static member functions, not __lambda2 Lambda's are delegates and delegates have a "this" type of pointer. I would like to get at it

Get relative offset portably.

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
I am doing some weird stuff. I duplicate functions and modify them in a portable way. One problem I have is that I cannot get data in a relative way to be able to access attached functional data. Here is an kinda of thought example, void base(int a, int b, int c) { ... } This function

Re: Convert delegate or function type to other.

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
On Monday, 18 July 2016 at 20:15:30 UTC, John wrote: On Monday, 18 July 2016 at 18:49:22 UTC, Rufus Smith wrote: Suppose I have the following: alias func = void function(int); Is there a way to convert it automatically to something the same type except of delegate: alias del = toDel(func) =

How to get the "this" ptr of a lambda inside the lambda?

2016-07-19 Thread Rufus Smith via Digitalmars-d-learn
Error: 'this' is only defined in non-static member functions, not __lambda2 Lambda's are delegates and delegates have a "this" type of pointer. I would like to get at it inside the lambda to check for some things. I'm doing some funky stuff. I'm not concerned about the scope or what this

Re: Convert delegate or function type to other.

2016-07-18 Thread Rufus Smith via Digitalmars-d-learn
On Monday, 18 July 2016 at 18:51:29 UTC, Jacob Carlborg wrote: On 2016-07-18 20:49, Rufus Smith wrote: Suppose I have the following: alias func = void function(int); Is there a way to convert it automatically to something the same type except of delegate: alias del = toDel(func) = void

Convert delegate or function type to other.

2016-07-18 Thread Rufus Smith via Digitalmars-d-learn
Suppose I have the following: alias func = void function(int); Is there a way to convert it automatically to something the same type except of delegate: alias del = toDel(func) = void delegate(int);?

Fast MSB to LSB

2016-07-17 Thread Rufus Smith via Digitalmars-d-learn
Is there any MSB to LSB and vice versa in phobos? Or some tricks with templates that make it fast as possible?