Re: Inline Module / Namespace

2018-03-09 Thread Jonathan M Davis via Digitalmars-d
gt; I think a simple way to do this with existing syntax is to add > functionality for `module` to be used as a block. > > > module modulename { > void fun(){} > } > modulename.fun(); > > > An inline module. You can always do something like declare a f

Re: Inline Module / Namespace

2018-03-09 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 9 March 2018 at 18:51:50 UTC, Manu wrote: If you tried to `import modulename;` from some other module... how would the compiler know where to find it? The compiler has to parse the module to find them correctly already. When you do foo.bar into foo/bar.d, it is just the first guess

Re: Inline Module / Namespace

2018-03-09 Thread Timothee Cour via Digitalmars-d
ntax is to add functionality >> for `module` to be used as a block. >> >> >> module modulename { >> void fun(){} >> } >> modulename.fun(); >> >> >> An inline module. > > If you tried to `import modulename;` from some other module... how > would the compiler know where to find it?

Re: Inline Module / Namespace

2018-03-09 Thread Manu via Digitalmars-d
me how to > code.) > > I think a simple way to do this with existing syntax is to add functionality > for `module` to be used as a block. > > > module modulename { > void fun(){} > } > modulename.fun(); > > > An inline module. If you tri

Inline Module / Namespace

2018-03-09 Thread Jonathan via Digitalmars-d
o add functionality for `module` to be used as a block. module modulename { void fun(){} } modulename.fun(); An inline module.

Re: Inline code in the docs - the correct way

2018-02-05 Thread Timon Gehr via Digitalmars-d
On 05.02.2018 16:27, H. S. Teoh wrote: Apparently it's a prevailing style for Lisp and Lisp dialects like Scheme. Random example (this is in Guile, a Scheme dialect, quoted from open source code): (define (match-predicate obj alist) (if (null? alist) "Unknown ty

Re: Inline code in the docs - the correct way OT: lisp

2018-02-05 Thread H. S. Teoh via Digitalmars-d
On Mon, Feb 05, 2018 at 06:38:22PM +, Patrick Schluter via Digitalmars-d wrote: [...] > When I programmed AutoLISP extension in AutoCAD I would use > parentheses in the exact same way as I use { } in C. So not at the end > of a line but vertically at the level of indentation; > > (defun x

Re: Inline code in the docs - the correct way OT: lisp

2018-02-05 Thread Patrick Schluter via Digitalmars-d
On Monday, 5 February 2018 at 14:50:38 UTC, Steven Schveighoffer wrote: On 2/5/18 1:27 AM, H. S. Teoh wrote: On Sun, Feb 04, 2018 at 02:34:31PM -0500, Steven Schveighoffer via Digitalmars-d wrote: [...] I don't have a hard time with braces. It tends to be worse with parentheses. Generally the

Re: Inline code in the docs - the correct way

2018-02-05 Thread bachmeier via Digitalmars-d
On Monday, 5 February 2018 at 15:27:56 UTC, H. S. Teoh wrote: On Mon, Feb 05, 2018 at 09:50:38AM -0500, Steven Schveighoffer via Digitalmars-d wrote: On 2/5/18 1:27 AM, H. S. Teoh wrote: > On Sun, Feb 04, 2018 at 02:34:31PM -0500, Steven > Schveighoffer via Digitalmars-d wrote: [...] > > I don'

Re: Inline code in the docs - the correct way

2018-02-05 Thread H. S. Teoh via Digitalmars-d
On Mon, Feb 05, 2018 at 09:50:38AM -0500, Steven Schveighoffer via Digitalmars-d wrote: > On 2/5/18 1:27 AM, H. S. Teoh wrote: > > On Sun, Feb 04, 2018 at 02:34:31PM -0500, Steven Schveighoffer via > > Digitalmars-d wrote: > > [...] > > > I don't have a hard time with braces. It tends to be worse

Re: Inline code in the docs - the correct way

2018-02-05 Thread Steven Schveighoffer via Digitalmars-d
On 2/5/18 1:27 AM, H. S. Teoh wrote: On Sun, Feb 04, 2018 at 02:34:31PM -0500, Steven Schveighoffer via Digitalmars-d wrote: [...] I don't have a hard time with braces. It tends to be worse with parentheses. Generally these are indented properly, and not } all on one line. Wait till you

Re: Inline code in the docs - the correct way

2018-02-05 Thread Steven Schveighoffer via Digitalmars-d
On 2/5/18 2:53 AM, Walter Bright wrote: On 2/4/2018 11:34 AM, Steven Schveighoffer wrote: On 2/2/18 7:10 PM, Walter Bright wrote: On 2/1/2018 6:09 AM, Steven Schveighoffer wrote: On 1/31/18 9:58 PM, Walter Bright wrote: On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: Where it breaks down is

Re: Inline code in the docs - the correct way

2018-02-04 Thread Walter Bright via Digitalmars-d
On 2/4/2018 11:34 AM, Steven Schveighoffer wrote: On 2/2/18 7:10 PM, Walter Bright wrote: On 2/1/2018 6:09 AM, Steven Schveighoffer wrote: On 1/31/18 9:58 PM, Walter Bright wrote: On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: Where it breaks down is when you have many nested tags, and you

Re: Inline code in the docs - the correct way

2018-02-04 Thread Seb via Digitalmars-d
On Monday, 5 February 2018 at 06:27:02 UTC, H. S. Teoh wrote: On Sun, Feb 04, 2018 at 02:34:31PM -0500, Steven Schveighoffer via Digitalmars-d wrote: [...] I don't have a hard time with braces. It tends to be worse with parentheses. Generally these are indented properly, and not } all on o

Re: Inline code in the docs - the correct way

2018-02-04 Thread H. S. Teoh via Digitalmars-d
On Sun, Feb 04, 2018 at 02:34:31PM -0500, Steven Schveighoffer via Digitalmars-d wrote: [...] > I don't have a hard time with braces. It tends to be worse with > parentheses. Generally these are indented properly, and not } all > on one line. Wait till you see Lisp code. :-P > Note: if the

Re: Inline code in the docs - the correct way

2018-02-04 Thread Steven Schveighoffer via Digitalmars-d
On 2/2/18 7:10 PM, Walter Bright wrote: On 2/1/2018 6:09 AM, Steven Schveighoffer wrote: On 1/31/18 9:58 PM, Walter Bright wrote: On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: Where it breaks down is when you have many nested tags, and you end with ) Long ago, I adjusted my text edit

Re: Inline code in the docs - the correct way

2018-02-03 Thread H. S. Teoh via Digitalmars-d
On Sat, Feb 03, 2018 at 06:25:26PM +, Adam D. Ruppe via Digitalmars-d wrote: > On Saturday, 3 February 2018 at 17:20:35 UTC, H. S. Teoh wrote: > > I got sick of just whining about, and decided to do something about > > it instead: > > Whelp, g'luck. I've tried to null out the macro before, may

Re: Inline code in the docs - the correct way

2018-02-03 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 3 February 2018 at 17:20:35 UTC, H. S. Teoh wrote: I got sick of just whining about, and decided to do something about it instead: Whelp, g'luck. I've tried to null out the macro before, maybe this approach will work better. The stupid thing should just be killed entirely though

Re: Inline code in the docs - the correct way

2018-02-03 Thread H. S. Teoh via Digitalmars-d
On Sat, Feb 03, 2018 at 06:18:55AM -0800, H. S. Teoh via Digitalmars-d wrote: > On Sat, Feb 03, 2018 at 04:37:44AM +, Adam D. Ruppe via Digitalmars-d > wrote: > [...] > > (note that the stupid leading _ is something I strip out too. Ddoc's > > most moronic "feature". Can we PLEASE kill that?!?

Re: Inline code in the docs - the correct way

2018-02-03 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 3 February 2018 at 11:41:27 UTC, Seb wrote: I think that would only work if we drop the ddoc of phobos entirely or add a similar feature to ddoc. I could live with either :P But the underscore thing is just plain bad. Literally NOBODY has ever liked it - every time this comes up,

Re: Inline code in the docs - the correct way

2018-02-03 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 3 February 2018 at 11:44:44 UTC, Seb wrote: Have you thought of simply postprocessing REF_ALTTEXT for your documentation engine for now? It actually supports the macro, so I could just keep the upstream source here, just the difference between them is kinda striking. The history

Re: Inline code in the docs - the correct way

2018-02-03 Thread H. S. Teoh via Digitalmars-d
On Sat, Feb 03, 2018 at 04:37:44AM +, Adam D. Ruppe via Digitalmars-d wrote: [...] > I'm updating my fork now and check out this merge conflict: > > <<< HEAD > * source = The [isInputRange|input range] to encode. > === > * source = The $(REF_ALTTEXT input range, isInputRang

Re: Inline code in the docs - the correct way

2018-02-03 Thread Seb via Digitalmars-d
On Saturday, 3 February 2018 at 04:37:44 UTC, Adam D. Ruppe wrote: On Friday, 2 February 2018 at 20:15:11 UTC, H. S. Teoh wrote: This is the kind of thing you should be promoting to Andrei to convince him that dpldocs is better. ;-) I'm updating my fork now and check out this merge conflict:

Re: Inline code in the docs - the correct way

2018-02-03 Thread Seb via Digitalmars-d
On Saturday, 3 February 2018 at 04:37:44 UTC, Adam D. Ruppe wrote: On Friday, 2 February 2018 at 20:15:11 UTC, H. S. Teoh wrote: This is the kind of thing you should be promoting to Andrei to convince him that dpldocs is better. ;-) I'm updating my fork now and check out this merge conflict:

Re: Inline code in the docs - the correct way

2018-02-02 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 2 February 2018 at 20:15:11 UTC, H. S. Teoh wrote: This is the kind of thing you should be promoting to Andrei to convince him that dpldocs is better. ;-) I'm updating my fork now and check out this merge conflict: <<< HEAD * source = The [isInputRange|input range] to enco

Re: Inline code in the docs - the correct way

2018-02-02 Thread Walter Bright via Digitalmars-d
On 2/1/2018 6:09 AM, Steven Schveighoffer wrote: On 1/31/18 9:58 PM, Walter Bright wrote: On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: Where it breaks down is when you have many nested tags, and you end with ) Long ago, I adjusted my text editor so that when the cursor is placed on )

Re: Inline code in the docs - the correct way

2018-02-02 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 2 February 2018 at 20:15:11 UTC, H. S. Teoh wrote: This is the kind of thing you should be promoting to Andrei to convince him that dpldocs is better. ;-) I've laid out my arguments several times, including this point. Actually, $(REF) was introduced after I made the argument, so it

Re: Inline code in the docs - the correct way

2018-02-02 Thread H. S. Teoh via Digitalmars-d
On Fri, Feb 02, 2018 at 07:46:51PM +, Adam D. Ruppe via Digitalmars-d wrote: > On Friday, 2 February 2018 at 18:45:50 UTC, H. S. Teoh wrote: > > In an ideal world, you wouldn't need to encode any of this stuff > > inside a ddoc comment. > > Well, that's what the Phobos REF macro does... sort o

Re: Inline code in the docs - the correct way

2018-02-02 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 2 February 2018 at 18:45:50 UTC, H. S. Teoh wrote: In an ideal world, you wouldn't need to encode any of this stuff inside a ddoc comment. Well, that's what the Phobos REF macro does... sort of. You write $(REF symbolName, std, module) and the macro figures out the link. Though, ev

Re: Inline code in the docs - the correct way

2018-02-02 Thread H. S. Teoh via Digitalmars-d
On Fri, Feb 02, 2018 at 10:49:18AM -0700, Jonathan M Davis via Digitalmars-d wrote: > On Friday, February 02, 2018 15:12:45 Adam D. Ruppe via Digitalmars-d wrote: > > On Thursday, 1 February 2018 at 02:10:22 UTC, Jonathan M Davis > > > IMHO, the main problem with ddoc for documentation is that it

Re: Inline code in the docs - the correct way

2018-02-02 Thread Jonathan M Davis via Digitalmars-d
On Friday, February 02, 2018 15:12:45 Adam D. Ruppe via Digitalmars-d wrote: > On Thursday, 1 February 2018 at 02:10:22 UTC, Jonathan M Davis > > IMHO, the main problem with ddoc for documentation is that it > > doesn't automatically handle stuff like cross-links, and it > > fundamentally can't, be

Re: Inline code in the docs - the correct way

2018-02-02 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 1 February 2018 at 02:10:22 UTC, Jonathan M Davis wrote: Personally, I hate markdown, because it makes certain syntax magical - e.g. it's not uncommon that a commit message ends up looking bad when github uses it as the message for a PR, because some piece of code contained * or so

Re: Inline code in the docs - the correct way

2018-02-01 Thread H. S. Teoh via Digitalmars-d
On Thu, Feb 01, 2018 at 09:09:28AM -0500, Steven Schveighoffer via Digitalmars-d wrote: > On 1/31/18 9:58 PM, Walter Bright wrote: > > On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: > > > Where it breaks down is when you have many nested tags, and you > > > end with ) > > > > Long ago, I a

Re: Inline code in the docs - the correct way

2018-02-01 Thread Steven Schveighoffer via Digitalmars-d
On 1/31/18 9:58 PM, Walter Bright wrote: On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: Where it breaks down is when you have many nested tags, and you end with ) Long ago, I adjusted my text editor so that when the cursor is placed on ), the matching ( is found. Ditto for { }, [ ], <

Re: Inline code in the docs - the correct way

2018-02-01 Thread Jakub Łabaj via Digitalmars-d
I can see that ddoc is a pretty hot topic here ;) On Thursday, 1 February 2018 at 01:27:43 UTC, Adam D. Ruppe wrote: To give you a quick answer, the tide is going toward ``. You should probably just use it in most cases as long as the code fits on a single line. If it is a multi-line sample, us

Re: Inline code in the docs - the correct way

2018-02-01 Thread Seb via Digitalmars-d
On Thursday, 1 February 2018 at 01:27:43 UTC, Adam D. Ruppe wrote: On Wednesday, 31 January 2018 at 15:40:04 UTC, Jakub Łabaj wrote: What is the current state of the art of writing inline code in the documentation? To give you a quick answer, the tide is going toward ``. You should probably

Re: Inline code in the docs - the correct way

2018-01-31 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, January 31, 2018 18:58:29 Walter Bright via Digitalmars-d wrote: > On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: > > Where it breaks down is when you have many nested tags, and you end with > > ) > Long ago, I adjusted my text editor so that when the cursor is placed on > ),

Re: Inline code in the docs - the correct way

2018-01-31 Thread Walter Bright via Digitalmars-d
On 1/31/2018 5:37 PM, Steven Schveighoffer wrote: Where it breaks down is when you have many nested tags, and you end with ) Long ago, I adjusted my text editor so that when the cursor is placed on ), the matching ( is found. Ditto for { }, [ ], < >, and #if/#elif/#else/#endif (!). It's b

Re: Inline code in the docs - the correct way

2018-01-31 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, January 31, 2018 16:19:53 H. S. Teoh via Digitalmars-d wrote: > In general, almost all text macro / formatting systems, from LaTeX to > HTML to ddoc, are universally ugly and verbose when it comes to tables, > and makes my eyes bleed. The only exception I've found so far is > > markdo

Re: Inline code in the docs - the correct way

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d
On 1/31/18 5:55 PM, Adam D. Ruppe wrote: Now though, inline code like $(D) and $(REF) are ambiguous. They are short enough that they'd normally fall into my "ok with it" zone like $(B)... but they are also so common and I want to encourage their use. And having three shifted

Re: Inline code in the docs - the correct way

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 31 January 2018 at 15:40:04 UTC, Jakub Łabaj wrote: What is the current state of the art of writing inline code in the documentation? To give you a quick answer, the tide is going toward ``. You should probably just use it in most cases as long as the code fits on a single line

Re: Inline code in the docs - the correct way

2018-01-31 Thread H. S. Teoh via Digitalmars-d
is in technical docs, so it's not a biggie. And I do still prefer *...* over $(B ...). I just don't like alphabetical macro names interspersed with text; it makes it hard to parse the text with the eye. > Now though, inline code like $(D) and $(REF) are ambiguous. They are > s

Re: Inline code in the docs - the correct way

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d
to the *markdown way* in some places, since at least the ddoc is deliberate. Only thing that bugs me is when I try to write :) or 1) or similar in there but I plan to fix that. Now though, inline code like $(D) and $(REF) are ambiguous. They are short enough that they'd normally fall into

Re: Inline code in the docs - the correct way

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 06:31:34PM +, Adam D. Ruppe via Digitalmars-d wrote: > On Wednesday, 31 January 2018 at 17:14:56 UTC, H. S. Teoh wrote: > > But otherwise, the two are equivalent. (In fact, backticks translate > > directly into $(D ...) in the ddoc code. They are just syntactic > > sugar

Re: Inline code in the docs - the correct way

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 31 January 2018 at 17:14:56 UTC, H. S. Teoh wrote: But otherwise, the two are equivalent. (In fact, backticks translate directly into $(D ...) in the ddoc code. They are just syntactic sugar.) No, they aren't. The `` is different in several ways including doing character escapin

Re: Inline code in the docs - the correct way

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 03:40:04PM +, Jakub Łabaj via Digitalmars-d wrote: > What is the current state of the art of writing inline code in the > documentation? > > Wiki says "use `...` instead of $(D ...)": > https://wiki.dlang.org/Contributing_to_Phobos#Docum

Inline code in the docs - the correct way

2018-01-31 Thread Jakub Łabaj via Digitalmars-d
What is the current state of the art of writing inline code in the documentation? Wiki says "use `...` instead of $(D ...)": https://wiki.dlang.org/Contributing_to_Phobos#Documentation_style. Some arguments made here: https://github.com/dlang/phobos/pull/5183#issuecomment-28189545

Re: Static inline field initialization

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d
On Wednesday, 23 August 2017 at 09:12:19 UTC, Kagamin wrote: On Tuesday, 22 August 2017 at 16:28:43 UTC, Moritz Maxeiner wrote: class Test { ubyte[] buf = new ubyte[1000]; // thread local storage, instances in the same thread refer to the same static array } Dynamic initialization is don

Re: Static inline field initialization

2017-08-23 Thread Kagamin via Digitalmars-d
On Tuesday, 22 August 2017 at 16:28:43 UTC, Moritz Maxeiner wrote: class Test { ubyte[] buf = new ubyte[1000]; // thread local storage, instances in the same thread refer to the same static array } Dynamic initialization is done by constructor: class Test { static ubyte[1000] s;

Re: Static inline field initialization

2017-08-22 Thread H. S. Teoh via Digitalmars-d
On Tue, Aug 22, 2017 at 04:28:43PM +, Moritz Maxeiner via Digitalmars-d wrote: [...] > I'd argue that - as new in this case doesn't allocate on the heap, but > in the resulting application's appropriate segments) - it should work > like this (from a language semantics standpoint): > > --- >

Re: Static inline field initialization

2017-08-22 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 22 August 2017 at 15:52:48 UTC, Kagamin wrote: On Tuesday, 22 August 2017 at 14:53:21 UTC, Moritz Maxeiner wrote: There is a bug [1] - as others have pointed out - that the static array isn't stored in TLS, but in global storage, however, but that doesn't apply in this single thread

Re: Static inline field initialization

2017-08-22 Thread Kagamin via Digitalmars-d
On Tuesday, 22 August 2017 at 14:53:21 UTC, Moritz Maxeiner wrote: There is a bug [1] - as others have pointed out - that the static array isn't stored in TLS, but in global storage, however, but that doesn't apply in this single threaded case. The initializer is copied from typeinfo, that can

Re: Static inline field initialization

2017-08-22 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 22 August 2017 at 12:38:50 UTC, Jonas Mminnberg wrote: On Tuesday, 22 August 2017 at 12:20:45 UTC, Moritz Maxeiner wrote: I agree that it can be confusing if you try to read it with C++ semantics [1]; the solution, however, imho is not to change D semantics or throw warnings [2]

Re: Static inline field initialization

2017-08-22 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 22 August 2017 at 13:53:05 UTC, Daniel Kozak wrote: s/buf/bug/ On Tue, Aug 22, 2017 at 3:52 PM, Daniel Kozak wrote: On Tue, Aug 22, 2017 at 2:20 PM, Moritz Maxeiner via Digitalmars-d < digitalmars-d@puremagic.com> wrote: On Tuesday, 22 August 2017 at 11:50:50 UTC, Jonas Mminnb

Re: Static inline field initialization

2017-08-22 Thread Kagamin via Digitalmars-d
https://issues.dlang.org/show_bug.cgi?id=2947

Re: Static inline field initialization

2017-08-22 Thread Daniel Kozak via Digitalmars-d
s/buf/bug/ On Tue, Aug 22, 2017 at 3:52 PM, Daniel Kozak wrote: > On Tue, Aug 22, 2017 at 2:20 PM, Moritz Maxeiner via Digitalmars-d < > digitalmars-d@puremagic.com> wrote: > >> On Tuesday, 22 August 2017 at 11:50:50 UTC, Jonas Mminnberg wrote: >> >>> ... >> >> >> I agree that it can be confusin

Re: Static inline field initialization

2017-08-22 Thread Daniel Kozak via Digitalmars-d
On Tue, Aug 22, 2017 at 2:20 PM, Moritz Maxeiner via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On Tuesday, 22 August 2017 at 11:50:50 UTC, Jonas Mminnberg wrote: > >> ... > > > I agree that it can be confusing if you try to read it with C++ semantics > [1]; the solution, however, imho

Re: Static inline field initialization

2017-08-22 Thread Steven Schveighoffer via Digitalmars-d
On 8/22/17 7:50 AM, Jonas Mminnberg wrote: Because of D's static initialization of members, this assert fails: class Test { ubyte[] buf = new ubyte[1000]; } void main() { auto a = new Test(); auto b = new Test(); assert(a.buf.ptr != b.buf.ptr); } This is bad, since; * It is

Re: Static inline field initialization

2017-08-22 Thread Jonas Mminnberg via Digitalmars-d
On Tuesday, 22 August 2017 at 12:20:45 UTC, Moritz Maxeiner wrote: I agree that it can be confusing if you try to read it with C++ semantics [1]; the solution, however, imho is not to change D semantics or throw warnings [2], but to refer to the D spec [3], which states that static initializ

Re: Static inline field initialization

2017-08-22 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 22 August 2017 at 11:50:50 UTC, Jonas Mminnberg wrote: Because of D's static initialization of members, this assert fails: class Test { ubyte[] buf = new ubyte[1000]; } void main() { auto a = new Test(); auto b = new Test(); assert(a.buf.ptr != b.buf.ptr); } This i

Static inline field initialization

2017-08-22 Thread Jonas Mminnberg via Digitalmars-d
Because of D's static initialization of members, this assert fails: class Test { ubyte[] buf = new ubyte[1000]; } void main() { auto a = new Test(); auto b = new Test(); assert(a.buf.ptr != b.buf.ptr); } This is bad, since; * It is not how C++ works * It introduces silent shari

Re: Inline aggregate types

2016-12-05 Thread Jacob Carlborg via Digitalmars-d
On 2016-12-05 13:32, Ethan Watson wrote: I also want to support statically sized bit arrays, Phobos only provides support for dynamically sized. That would be nice, I had a need for that. -- /Jacob Carlborg

Re: Inline aggregate types

2016-12-05 Thread Ethan Watson via Digitalmars-d
On Monday, 5 December 2016 at 11:57:18 UTC, Guillaume Chatelet wrote: Do you plan on contributing this back to phobos? I also came across this exact same problem. It'll want to go through a few polish iterations before I even think of doing that; and it'll need support for things like toStrin

Re: Inline aggregate types

2016-12-05 Thread Guillaume Chatelet via Digitalmars-d
On Friday, 2 December 2016 at 11:11:30 UTC, Ethan Watson wrote: On Friday, 2 December 2016 at 10:16:17 UTC, Jacob Carlborg wrote: [...] I was attempting to support all methods. new class isn't the cleanest way of doing things either, so I decided I'd support all the things and let the user c

Re: Inline aggregate types

2016-12-02 Thread Ethan Watson via Digitalmars-d
On Friday, 2 December 2016 at 10:16:17 UTC, Jacob Carlborg wrote: Using an alias without a template constraint works for me. I was attempting to support all methods. new class isn't the cleanest way of doing things either, so I decided I'd support all the things and let the user choose what t

Re: Inline aggregate types

2016-12-02 Thread Jacob Carlborg via Digitalmars-d
On 2016-12-02 10:11, Ethan Watson wrote: On Friday, 2 December 2016 at 08:33:17 UTC, Jacob Carlborg wrote: But wWhat about an anonymous class as ag0aep6g mentioned? Usability I see is something that is key here. Having to do a typeof yourself is one extra step away from an intuitive API. So I

Re: Inline aggregate types

2016-12-02 Thread Ethan Watson via Digitalmars-d
On Friday, 2 December 2016 at 08:33:17 UTC, Jacob Carlborg wrote: But wWhat about an anonymous class as ag0aep6g mentioned? Usability I see is something that is key here. Having to do a typeof yourself is one extra step away from an intuitive API. So I tried making a definition like this: m

Re: Inline aggregate types

2016-12-02 Thread Jacob Carlborg via Digitalmars-d
On 2016-12-01 21:31, Ethan Watson wrote: https://github.com/Remedy-Entertainment/binderoo/blob/master/binderoo_client/d/src/binderoo/bitpacking.d So I've been not-all-that-pleased with std.bitmanip.bitfields for a while. It's nice that it's there, but I'm binding to C++ objects where the meanin

Re: Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
On Thursday, 1 December 2016 at 20:31:32 UTC, Ethan Watson wrote: https://github.com/Remedy-Entertainment/binderoo/blob/master/binderoo_client/d/src/binderoo/bitpacking.d Stefan also reminded me that this would be a perfect spot where __symbol CTFE variables would make life much easier (especi

Re: Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
On Thursday, 1 December 2016 at 20:58:53 UTC, H. S. Teoh wrote: In cases like these, q{} comes to the rescue: I had precisely zero idea this existed.

Re: Inline aggregate types

2016-12-01 Thread H. S. Teoh via Digitalmars-d
On Thu, Dec 01, 2016 at 08:31:32PM +, Ethan Watson via Digitalmars-d wrote: [...] > So the invokation, while not as readable, looks like: > > mixin BitPack!( "@PackSize( 3 ) int iSomeInt = 3; @PackSize( 1 ) bool > bSomeBool = true; @PackSize( 4 ) int iSomeOtherInt;" ); > > I'm sure I just mad

Re: Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
On Thursday, 1 December 2016 at 20:57:13 UTC, Andrei Alexandrescu wrote: The simplest way to go here is to accept an initializer for the entire ubyte/ushort/uint/ulong underlying the bitfields. -- Andrei In terms of efficiency at compile time, indeed. But there's multiple paths there. You cou

Re: Inline aggregate types

2016-12-01 Thread Andrei Alexandrescu via Digitalmars-d
On 12/01/2016 03:31 PM, Ethan Watson wrote: I'm binding to C++ objects where the meaningful default values require those packed values to have initial values. It's rather painful to get that working with the Phobos implementation. The simplest way to go here is to accept an initializer for the

Re: Inline aggregate types

2016-12-01 Thread ag0aep6g via Digitalmars-d
On 12/01/2016 09:31 PM, Ethan Watson wrote: I'm also sure there's plenty of other legit uses for inline aggregate types. So while the feature doesn't exist in the language yet, at least you can now see that there's quite a legit hacky-as-all-fuck workaround for it. Inter

Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
while not as readable, looks like: mixin BitPack!( "@PackSize( 3 ) int iSomeInt = 3; @PackSize( 1 ) bool bSomeBool = true; @PackSize( 4 ) int iSomeOtherInt;" ); I'm sure I just made someone cry looking at that. I'm also sure there's plenty of other legit uses for inline

Re: writing DMD tests for inline assembly bugs

2015-10-30 Thread Cauterite via Digitalmars-d
This *seems* to fix it: https://github.com/D-Programming-Language/dmd/pull/5244 On Thursday, 29 October 2015 at 12:44:51 UTC, Cauterite wrote: while working on issue 15235 I've been trying to add some new tests for DMD.

Re: writing DMD tests for inline assembly bugs

2015-10-30 Thread Jacob Carlborg via Digitalmars-d
will work pretty good as long as the code inside the string literals are fairly short. Another advantage would be that any specific compiler flags that are required for a given test can be passed as a separate argument instead of being inline in the source code as a comment. -- /Jacob

Re: writing DMD tests for inline assembly bugs

2015-10-29 Thread Walter Bright via Digitalmars-d
On 10/29/2015 5:44 AM, Cauterite wrote: while working on issue 15235 I've been trying to add some new tests for DMD. The tests I want to write involve checking that certain asm statements throw syntax errors instead of segfaults, but the fact that asmerr() ends compilation unconditionally is pro

writing DMD tests for inline assembly bugs

2015-10-29 Thread Cauterite via Digitalmars-d
while working on issue 15235 I've been trying to add some new tests for DMD. The tests I want to write involve checking that certain asm statements throw syntax errors instead of segfaults, but the fact that asmerr() ends compilation unconditionally is proving to be a problem. __traits(compil

Re: pragma(inline, true) not very useful in its current state?

2015-09-27 Thread Marco Leise via Digitalmars-d
state and always safe; for the cases > >> where it's /undesirable/, there is noinline. > > > > No what I meant was when the compiler sees inline assembly or > > anything else it deems not safe to inline, you can convice it > > anyways. It is more like @trus

Re: pragma(inline, true) not very useful in its current state?

2015-09-27 Thread Artur Skawina via Digitalmars-d
what I meant was when the compiler sees inline assembly or > anything else it deems not safe to inline, you can convice it > anyways. It is more like @trusted on otherwise @system > functions. I just mentioned it so it is under consideration, > as I have seen it in LLVM. The problem wi

Re: pragma(inline, true) not very useful in its current state?

2015-09-27 Thread Marco Leise via Digitalmars-d
Am Sat, 26 Sep 2015 19:58:14 +0200 schrieb Artur Skawina via Digitalmars-d : > `allow` is the default state and always safe; for the cases > where it's /undesirable/, there is noinline. > > artur No what I meant was when the compiler sees inline assembly or anything else it

Re: pragma(inline, true) not very useful in its current state?

2015-09-27 Thread Marco Leise via Digitalmars-d
Am Sat, 26 Sep 2015 21:11:07 +0200 schrieb Jacob Carlborg : > On 2015-09-26 18:42, Marco Leise wrote: > > > Maybe the compiler devs can decide on more common syntax like > > a generic core.attribute or just use pragma for inlining, but > > extend it so that it offers more options: > > Yeah, we a

Re: pragma(inline, true) not very useful in its current state?

2015-09-26 Thread Jacob Carlborg via Digitalmars-d
On 2015-09-26 18:42, Marco Leise wrote: Maybe the compiler devs can decide on more common syntax like a generic core.attribute or just use pragma for inlining, but extend it so that it offers more options: Yeah, we already have core.attribute. Now they just have to agree on the name :) -- /

Re: pragma(inline, true) not very useful in its current state?

2015-09-26 Thread Johannes Pfau via Digitalmars-d
ly since LDC/GDC have compiler-specific > > > attributes that DMD doesn't recognise. > > > > I'm not sure how much this helps but can't you use a dummy UDA on > > DMD for the GDC/LDC attributes? > > pragma(inline, true) void foo() > @gcc.attribute.at

Re: pragma(inline, true) not very useful in its current state?

2015-09-26 Thread Artur Skawina via Digitalmars-d
C/GDC have compiler-specific attributes >>> that DMD doesn't recognise. >> >> I'm not sure how much this helps but can't you use a dummy UDA on DMD >> for the GDC/LDC attributes? > > pragma(inline, true) void foo() @gcc.attribute.attrib

Re: pragma(inline, true) not very useful in its current state?

2015-09-26 Thread Marco Leise via Digitalmars-d
t; > I'm not sure how much this helps but can't you use a dummy UDA on DMD > for the GDC/LDC attributes? pragma(inline, true) void foo() @gcc.attribute.attribute("forceinline") @ldc.attribute.attribute("alwaysinline") @safe pure nothrow @nogc { // O

Re: pragma(inline, true) not very useful in its current state?

2015-09-26 Thread Jacob Carlborg via Digitalmars-d
On 2015-09-26 06:27, Manu via Digitalmars-d wrote: We _really_ need attribute aliasing in some form, especially since LDC/GDC have compiler-specific attributes that DMD doesn't recognise. I'm not sure how much this helps but can't you use a dummy UDA on DMD for the GDC/LDC attributes? -- /J

Re: pragma(inline, true) not very useful in its current state?

2015-09-26 Thread Dmitry Olshansky via Digitalmars-d
ng, otherwise D wouldn't be so much like C++ to begin with. __forceinline in C++ is exactly what people want here. The behaviour is useful, and well understood; compiler will always inline if possible, and warn if it can't. There's nothing wrong with C++ in this case, and I wish D woul

Re: pragma(inline, true) not very useful in its current state?

2015-09-25 Thread Iain Buclaw via Digitalmars-d
On 24 Sep 2015 9:46 pm, "Walter Bright via Digitalmars-d" < digitalmars-d@puremagic.com> wrote: > > On 9/24/2015 8:47 AM, David Nadlinger wrote: >> >> What were the reasons behind this decision? > > > The trouble is the compiler does inlining as a top dow

Re: pragma(inline, true) not very useful in its current state?

2015-09-25 Thread Iain Buclaw via Digitalmars-d
rong, otherwise D wouldn't be so much > like C++ to begin with. __forceinline in C++ is exactly what people > want here. The behaviour is useful, and well understood; compiler will > always inline if possible, and warn if it can't. There's nothing wrong > with C++ in

Re: pragma(inline, true) not very useful in its current state?

2015-09-25 Thread Manu via Digitalmars-d
by decades of use and millions of developers, remaining as people expect them to be... then yes. C++ didn't get *everything* wrong, otherwise D wouldn't be so much like C++ to begin with. __forceinline in C++ is exactly what people want here. The behaviour is useful, and well understood

Re: pragma(inline, true) not very useful in its current state?

2015-09-25 Thread Manu via Digitalmars-d
looking into the remaining 2.068 test failures >> for LDC, I was surprised to find out that DMD only honors pragma(inline, >> true) when -inline is actually passed on the command line. >> >> This seems to be completely against what many people I spoke to >> (inclu

Re: pragma(inline, true) not very useful in its current state?

2015-09-24 Thread Walter Bright via Digitalmars-d
On 9/24/2015 8:47 AM, David Nadlinger wrote: What were the reasons behind this decision? The trouble is the compiler does inlining as a top down traversal, whereas forcing inline with no -inline would be a bottom up thing. The compiler could always do the top down traversal, but it would

Re: pragma(inline, true) not very useful in its current state?

2015-09-24 Thread Jack Stouffer via Digitalmars-d
On Thursday, 24 September 2015 at 15:47:45 UTC, David Nadlinger wrote: which is to force inlining of certain functions even in debug builds. I don't understand what the problem is. Just pass -inline in your debug build.

Re: pragma(inline, true) not very useful in its current state?

2015-09-24 Thread John Colvin via Digitalmars-d
On Thursday, 24 September 2015 at 15:47:45 UTC, David Nadlinger wrote: Hi all, I'm not even referring to the multitude of restrictions in the DMD frontend inliner here. When looking into the remaining 2.068 test failures for LDC, I was surprised to find out that DMD only honors pragma(i

pragma(inline, true) not very useful in its current state?

2015-09-24 Thread David Nadlinger via Digitalmars-d
Hi all, I'm not even referring to the multitude of restrictions in the DMD frontend inliner here. When looking into the remaining 2.068 test failures for LDC, I was surprised to find out that DMD only honors pragma(inline, true) when -inline is actually passed on the command line.

Re: force inline/not-inline

2015-08-04 Thread ketmar via Digitalmars-d
On Wed, 29 Jul 2015 18:35:36 +, David Nadlinger wrote: > On Wednesday, 29 July 2015 at 04:26:36 UTC, ketmar wrote: >> yet "that ship has sailed", i think. > > It hasn't yet. 2.068.0 will be the first release to include the pragma. but one has to convince Walter, and it's not the easiest thin

Re: force inline/not-inline

2015-07-31 Thread Daniel Murphy via Digitalmars-d
"Steven Schveighoffer" wrote in message news:mp86be$8f2$1...@digitalmars.com... the only thing I can thing of is that true/false are (or have the potential to be in this context) expressions, which means one could use compile-time logic to specify inlining. The same wouldn't be true of arbit

Re: force inline/not-inline

2015-07-31 Thread Kagamin via Digitalmars-d
On Tuesday, 28 July 2015 at 22:12:21 UTC, David Nadlinger wrote: I do think it is terribly confusing. pragma(inline) does not cause any inlining by itself at all. It just means to let the compiler do what it normally does (i.e. try to inline if -inline is specified). I suppose people were

  1   2   3   4   >