Re: Big Oversight with readln?

2017-02-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 24 February 2017 at 07:38:04 UTC, Mike Parker wrote: On Friday, 24 February 2017 at 04:22:17 UTC, Jonathan Marler wrote: I discovered the .capacity property of arrays. I don't know why I've never seen this but it looks like this is how readln is recovering this seemingly lost

Re: Big Oversight with readln?

2017-02-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 24 February 2017 at 04:22:17 UTC, Jonathan Marler wrote: I discovered the .capacity property of arrays. I don't know why I've never seen this but it looks like this is how readln is recovering this seemingly lost peice of data. This does have an odd consequence though, if you

Re: RAII

2017-02-23 Thread ketmar via Digitalmars-d-learn
Arun Chandrasekaran wrote: On Thursday, 23 February 2017 at 09:57:09 UTC, ketmar wrote: Thanks for your help. NRVO looks interesting. However this may not be RAII after all. Or may be too much of C++ has spoiled me. I am not familiar enough with D to appreciate/question the language design

Re: RAII

2017-02-23 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Thursday, 23 February 2017 at 21:05:48 UTC, cym13 wrote: It reminds me of https://w0rp.com/blog/post/an-raii-constructor-by-another-name-is-just-as-sweet/ which isn't what you want but may be interesting anyway. It is interesting, indeed, thanks.

Re: RAII

2017-02-23 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Thursday, 23 February 2017 at 09:57:09 UTC, ketmar wrote: Arun Chandrasekaran wrote: I'm trying to write an RAII wrapper on Linux. I understand struct in D doesn't have default constructor (for .init reasons). I don't want to use `scope`. Is there an elegant way to achieve this in D?

Re: Big Oversight with readln?

2017-02-23 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 24 February 2017 at 03:45:35 UTC, Nick Sabalausky (Abscissa) wrote: On 02/23/2017 09:43 PM, Jonathan Marler wrote: I can't figure out how to make use of the full capacity of buffers that are allocated by readln. Take the example code from the documentation: // Read lines

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 10:36 PM, Adam D. Ruppe wrote: On Friday, 24 February 2017 at 02:50:27 UTC, Nick Sabalausky (Abscissa) wrote: What I'd kinda like to do is put together a D doc generator that uses, uhh, probably markdown. My dpldocs.info generator continues to progress and I'm almost ready to

Re: Big Oversight with readln?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 09:43 PM, Jonathan Marler wrote: I can't figure out how to make use of the full capacity of buffers that are allocated by readln. Take the example code from the documentation: // Read lines from $(D stdin) and count words void main() { char[] buf;

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 24 February 2017 at 02:50:27 UTC, Nick Sabalausky (Abscissa) wrote: What I'd kinda like to do is put together a D doc generator that uses, uhh, probably markdown. My dpldocs.info generator continues to progress and I'm almost ready to call it beta and let other people use it.

Re: Debugging D applications from VS code with webfreak.debug

2017-02-23 Thread Jerry via Digitalmars-d-learn
You can use the C++ plugin, which provides a debugger. Just make sure you aren't using optlink, I don't think it generates compatible files. Also you might need to use "-gc" which generates debug names to be in C format. https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 04:34 PM, Ali Çehreli wrote: (None of the following is tested.) a) Try using the following macro: COLON = And then use "Note$(COLON) Blah". Thanks, that works. c) Another option: NOTE = Note $0 Then use "$(NOTE Blah)" Actually, that's more or less what I was

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 04:49 PM, H. S. Teoh via Digitalmars-d-learn wrote: I'm becoming more and more convinced that software that tries to be smart ends up being even dumber than before. I've been convinced of that for a long time ;) Not just software either. Anything. My car does idiotic "smart"

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 04:51 PM, Adam D. Ruppe wrote: On Thursday, 23 February 2017 at 21:39:11 UTC, H. S. Teoh Apparently COLON is defined to be ':' in the default ddoc macros, so you needn't define it yourself. Oh yeah. Still, barf. Luckily in my case, the "Word:" part is already generated inside

Big Oversight with readln?

2017-02-23 Thread Jonathan Marler via Digitalmars-d-learn
I can't figure out how to make use of the full capacity of buffers that are allocated by readln. Take the example code from the documentation: // Read lines from $(D stdin) and count words void main() { char[] buf; size_t words = 0; while (!stdin.eof)

Re: ddoc: Can I escape a colon?

2017-02-23 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 23, 2017 at 01:39:11PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > Nah, that's overkill. This works: > > Note$(COLON) blah blah blah > > Apparently COLON is defined to be ':' in the default ddoc macros, so > you needn't define it yourself. [...] Bah, I was wrong,

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 February 2017 at 21:39:11 UTC, H. S. Teoh Apparently COLON is defined to be ':' in the default ddoc macros, so you needn't define it yourself. Oh yeah. Still, barf.

Re: ddoc: Can I escape a colon?

2017-02-23 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 23, 2017 at 09:35:41PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Thursday, 23 February 2017 at 21:17:33 UTC, H. S. Teoh wrote: > > _Note: Blah blabbety blah > > Nope. > > Ddoc considers [A-Za-z_]+: to be a section header. You can trick it by > doing something like

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 February 2017 at 21:17:33 UTC, H. S. Teoh wrote: _Note: Blah blabbety blah Nope. Ddoc considers [A-Za-z_]+: to be a section header. You can trick it by doing something like /++ Note: ass +/ Yes, the html entity for a space. That trick's ddoc's stupid parser while

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Ali Çehreli via Digitalmars-d-learn
On 02/23/2017 01:04 PM, Nick Sabalausky (Abscissa) wrote: Suppose I want ddoc output to include this line: -- Note: Blah blabbety blah -- But the colon causes "Note" to be considered a section header. Is there a way to escape the ":" so that it's displayed as expected,

Re: ddoc: Can I escape a colon?

2017-02-23 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 23, 2017 at 04:04:39PM -0500, Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > Suppose I want ddoc output to include this line: > > -- > Note: Blah blabbety blah > -- > > But the colon causes "Note" to be considered a section header. Is > there a

Re: RAII

2017-02-23 Thread cym13 via Digitalmars-d-learn
On Thursday, 23 February 2017 at 09:52:26 UTC, Arun Chandrasekaran wrote: I'm trying to write an RAII wrapper on Linux. I understand struct in D doesn't have default constructor (for .init reasons). I don't want to use `scope`. Is there an elegant way to achieve this in D? ``` import

ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
Suppose I want ddoc output to include this line: -- Note: Blah blabbety blah -- But the colon causes "Note" to be considered a section header. Is there a way to escape the ":" so that it's displayed as expected, but doesn't trigger a section?

Re: simple static if / traits question...

2017-02-23 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 23 February 2017 at 18:35:29 UTC, Profile Anaysis wrote: [...] option 1 is the one I was shooting for. does the static if (audio) just check for the existence of audio, or does it also check to see if audio is true as well? Yes, but it checks at compile time. So the code

Re: Checking, whether string contains only ascii.

2017-02-23 Thread berni via Digitalmars-d-learn
On Thursday, 23 February 2017 at 17:44:05 UTC, HeiHon wrote: Generally postscript files may contain binary data. Think of included images or font data. So in postscript files there should normally be no utf-8 encoded text, but binary data are quite usual. Think of postscript files as a

Re: RAII

2017-02-23 Thread kinke via Digitalmars-d-learn
On Thursday, 23 February 2017 at 18:46:58 UTC, kinke wrote: A constructor is just a factory function with a special name... Wrt. the special name, that's obviously extremely useful for generic templates (containers etc.).

Re: RAII

2017-02-23 Thread kinke via Digitalmars-d-learn
On Thursday, 23 February 2017 at 14:24:14 UTC, Adam D. Ruppe wrote: On Thursday, 23 February 2017 at 10:48:38 UTC, kinke wrote: That's not elegant. You need a factory function for each type containing one of these structs then. A constructor is just a factory function with a special name...

Re: Debugging D applications from VS code with webfreak.debug

2017-02-23 Thread FR via Digitalmars-d-learn
On Thursday, 23 February 2017 at 17:54:09 UTC, FR wrote: gdb is in my path, I can run it from the command line. When I run 'gdb test.exe' (test.exe being the binary placed in my workspace folder), I get the error message "not in executable format: File format not recognized", whether I build

Re: simple static if / traits question...

2017-02-23 Thread Profile Anaysis via Digitalmars-d-learn
There are a few options: 1. static if(audio) 2. version(audio) 3. if (audio) It looks like you are trying to create the version(audio) semantic(if exists then use, else don't). Ultimately, though, if you are trying to make a binary that can either use audio or not depending on where it is

Re: template parameter inference and introspection

2017-02-23 Thread Meta via Digitalmars-d-learn
On Thursday, 23 February 2017 at 18:21:51 UTC, Meta wrote: On Thursday, 23 February 2017 at 16:01:44 UTC, John Colvin wrote: Is there any way to get a reference/alias to the instantiation of a template function that would be called, given certain parameters? I.e. to get the result of whatever

Re: template parameter inference and introspection

2017-02-23 Thread Meta via Digitalmars-d-learn
On Thursday, 23 February 2017 at 16:01:44 UTC, John Colvin wrote: Is there any way to get a reference/alias to the instantiation of a template function that would be called, given certain parameters? I.e. to get the result of whatever template parameter inference (and overload resolution) has

Re: Debugging D applications from VS code with webfreak.debug

2017-02-23 Thread FR via Digitalmars-d-learn
On Thursday, 23 February 2017 at 16:30:08 UTC, WebFreak001 wrote: I don't know how to build mago-mi either, but you can obtain it from the bundle with dlangide https://github.com/buggins/dlangide/releases/download/v0.6.11/dlangide-v0_6_11-bin-win32_x86-magomi-v0_3_1.zip Thanks, that got me

Re: Checking, whether string contains only ascii.

2017-02-23 Thread HeiHon via Digitalmars-d-learn
On Thursday, 23 February 2017 at 08:34:53 UTC, berni wrote: On Wednesday, 22 February 2017 at 21:23:45 UTC, H. S. Teoh wrote: enforce(!s.any!"a > 127"); Puh, it's lot's of possibilities to choose of, now... I thought of something like the foreach-loop but wasn't sure if that is

Re: Debugging D applications from VS code with webfreak.debug

2017-02-23 Thread WebFreak001 via Digitalmars-d-learn
On Thursday, 23 February 2017 at 16:28:26 UTC, FR wrote: Hi everyone, as the subject says, I'm trying to get a debugger running with visual studio code on windows. I have installed WebFreak001's code-d and debug extensions but fail to figure out how to install a working debugger. The gdb I

template parameter inference and introspection

2017-02-23 Thread John Colvin via Digitalmars-d-learn
Is there any way to get a reference/alias to the instantiation of a template function that would be called, given certain parameters? I.e. to get the result of whatever template parameter inference (and overload resolution) has occurred? E.g. for some arbitrarily complex foo: static

Re: RAII

2017-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 February 2017 at 10:48:38 UTC, kinke wrote: That's not elegant. You need a factory function for each type containing one of these structs then. A constructor is just a factory function with a special name... it is almost equal amount of work.

Re: RAII

2017-02-23 Thread Adrian Matoga via Digitalmars-d-learn
On Thursday, 23 February 2017 at 09:52:26 UTC, Arun Chandrasekaran wrote: I'm trying to write an RAII wrapper on Linux. I understand struct in D doesn't have default constructor (for .init reasons). I don't want to use `scope`. Is there an elegant way to achieve this in D? static opCall()

Re: RAII

2017-02-23 Thread kinke via Digitalmars-d-learn
On Thursday, 23 February 2017 at 09:57:09 UTC, ketmar wrote: Arun Chandrasekaran wrote: Is there an elegant way to achieve this in D? why not static method or free function that returns struct? due to NRVO[0] it won't even be copied. That's not elegant. You need a factory function for each

Re: JustQuestion: Are 'D' had a browser library?

2017-02-23 Thread dummy via Digitalmars-d-learn
On Sunday, 19 February 2017 at 09:21:40 UTC, aberba wrote: On Sunday, 19 February 2017 at 08:01:56 UTC, dummy wrote: [...] You can use any D lib with http GET support (Vibe.d[1]: download, requests[2]) at code.dlang.org. arsd.dom[3] has dom parsing support. or use any XML lib. [1]

Re: RAII

2017-02-23 Thread ketmar via Digitalmars-d-learn
Arun Chandrasekaran wrote: I'm trying to write an RAII wrapper on Linux. I understand struct in D doesn't have default constructor (for .init reasons). I don't want to use `scope`. Is there an elegant way to achieve this in D? why not static method or free function that returns struct? due

RAII

2017-02-23 Thread Arun Chandrasekaran via Digitalmars-d-learn
I'm trying to write an RAII wrapper on Linux. I understand struct in D doesn't have default constructor (for .init reasons). I don't want to use `scope`. Is there an elegant way to achieve this in D? ``` import core.sys.posix.pthread; import core.sys.posix.sys.types; /// Makes

Re: Checking, whether string contains only ascii.

2017-02-23 Thread berni via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 21:23:45 UTC, H. S. Teoh wrote: enforce(!s.any!"a > 127"); Puh, it's lot's of possibilities to choose of, now... I thought of something like the foreach-loop but wasn't sure if that is correct for all utf encodings. All in all, I think I take the