Re: Looking to get typeof parseXML return value
On Tuesday, 7 September 2021 at 04:40:25 UTC, jfondren wrote: typeof(parseXML!simpleXML("")) xml; Hey, I like this trick! I was wondering what to use for the const(char)[] variable in the typeof statement. It's blindingly obvious in retrospect. Wouldn't work so well if there wasn't a literal for the input data range type. Sorry, didn't see your response before I posted mine, but thanks for the tip anyway :)
Re: Looking to get typeof parseXML return value
On Tuesday, 7 September 2021 at 04:13:08 UTC, Chris Piker wrote: Any ideas on how to get the return type of `parseXML` below: ``` import dxml.parser; const(char)[] _mmfile; //_mmfile initialization TYPE??? _entityRng = parseXML!(simpleXML)(_mmfile); ``` Though it's ususally bad form to respond to one's own question. I hope to avoid wasting your time on this question. Just reading the source instead of trying to pull some typeof wizardry gives the answer: ``` EntityRange!(simpleXML, const(char)[]) _rEntity; _rEntity = parseXML!(simpleXML)(_data); ``` Sorry for the forum noise, carry on.
Re: Looking to get typeof parseXML return value
On Tuesday, 7 September 2021 at 04:13:08 UTC, Chris Piker wrote: Any ideas on how to get the return type of `parseXML` below: ``` import dxml.parser; const(char)[] _mmfile; //_mmfile initialization TYPE??? _entityRng = parseXML!(simpleXML)(_mmfile); ``` *before* calling parseXML, so that it can be a class member variable? Here's a quick script: ```d #! /usr/bin/env dub /++ dub.sdl: dependency "dxml" version="0.4.0" +/ import dxml.parser; import std.stdio : writeln; struct SomeXML { EntityRange!(simpleXML, string) xml; } struct Again { typeof(parseXML!simpleXML("")) xml; } void main() { auto xml = parseXML!simpleXML(""); pragma(msg, typeof(xml)); // compile time writeln(typeid(xml)); // runtime SomeXML some = SomeXML(xml); foreach (_; 0 .. 4) { writeln(some.xml.front); some.xml.popFront; } auto again = Again(xml); writeln(again.xml.front); } ``` EntityRange have two template parameters, a Config with four flags (where simpleXML has all flags set to yes) and the type of the forward range supplying characters to be parsed. So, `EntityRange!(simpleXML, string)` works as a type of those are really what you'll be using, `typeof(parseXML!simpleXML(""))` works as a type by seeing what type parseXML returns when invoked like that.
Looking to get typeof parseXML return value
Hi D I'm using the **dxml** library since I like it's "pull here for more data" mentality. I've come across the need to save an entity range created by the `parseXML` function as a class member so that I can tuck it away and pull more data as needed. Like almost all new users to D I'm tripping over how to save and pass around variables since nothing has an understandable type anymore and you can't use "auto" for *class member* storage types. Any ideas on how to get the return type of `parseXML` below: ``` import dxml.parser; const(char)[] _mmfile; //_mmfile initialization TYPE??? _entityRng = parseXML!(simpleXML)(_mmfile); ``` *before* calling parseXML, so that it can be a class member variable? I've tried variations on `typeof` and `.inputRangeObject` etc. with no success so far. Thanks for any advice :) All this would be so much easier if dxml just defined `Entity` at the top level of the parser module instead of burying it inside a templated struct. Then the type could just be `InputRange!Entity` which is easy to work with.
Re: Absence of isAllocator trait
On Monday, 6 September 2021 at 15:46:52 UTC, Paul Backus wrote: * `void allocate(size_t size)` Should be * `void[] allocate(size_t size)` Thanks. Here's what I have so far ```d enum isAllocator(T) = (is(typeof(T.allocate(size_t.init)) == void[]) && is(typeof(T.alignment) == uint)); ```
Re: Forum posting question ... how post a thread question with color syntax highlighting ??
On 9/6/21 10:13 AM, Mike Parker wrote: On Monday, 6 September 2021 at 13:23:21 UTC, Steven Schveighoffer wrote: I will note though, that some people use the mechanism for links that puts the link at the bottom of the post, and this can be annoying when you reply, if you don't include the link definition, it doesn't render correctly. Now that's interesting. I had assumed it would be less annoying than having them inline. Especially since people had already adopted a similar convention before we got Markdown support. I gave up on Thuderbird and went full-on with the web interface a couple of years ago, so I've had no view of the experience post-Markdown. Yeah the convention isn't terrible, but it looks weirder for sure when the link is missing. E.g. look at this post: https://forum.dlang.org/post/miahenxocgxpvasqg...@forum.dlang.org and then a reply: https://forum.dlang.org/post/jreujgbixqadnwjsi...@forum.dlang.org -Steve
Re: Absence of isAllocator trait
On Monday, 6 September 2021 at 13:24:56 UTC, Basile B. wrote: It's because the clients of an allocator should rather statically check for specific traits of an allocator, there are too many possible permutations of capabilities possible, not all can allocate and deallocate, not all can reallocate, and so on. According to [the documentation][1], there are two required properties all allocators must have: * `uint alignment` * `void allocate(size_t size)` So it makes sense to have an `isAllocator` trait that checks for those, even if clients are expected to check for other properties individually. [1]: https://dlang.org/phobos/std_experimental_allocator_building_blocks.html
DMD32 D Compiler v2.097.2-dirty ?
I like to write CLEAN code:) Why does my DMD installation say v2.097.2-dirty?
Re: Forum posting question ... how post a thread question with color syntax highlighting ??
On Monday, 6 September 2021 at 01:18:20 UTC, Ali Çehreli wrote: That's because I've been using Thunderbird for mail and news for a long time now and unfortunately it is impossible to convince Thunderbird to add the necessary header field. (Vladimir has a recommendation where I can run a simply local server that augments Thunderbird's headers but I haven't tried it yet.) I should go back to using Emacs for news. I am pretty sure it will be configurable. I used Thunderbird many many years and when Mozilla started doing stupid things to FireFox/Thunderbird (and almost abandoning Thunderbird by the way) I switched to ClawsMail and I can not be ever happier since then. Tiny, unobtrusive, extremely-fast, extremely-configurable, and guaranteed no-surprises-on-the-horizon which for me was the tipping point. Text-only mail only, no HTML/no-JavaScript, so bye-bye lots of possible attack-scenarios. I adopted ClawsMail when I switched from Windows to linux as my daily driver. If you feel giving it a try it is on https://www.claws-mail.org/.
Re: Forum posting question ... how post a thread question with color syntax highlighting ??
On Monday, 6 September 2021 at 13:23:21 UTC, Steven Schveighoffer wrote: I will note though, that some people use the mechanism for links that puts the link at the bottom of the post, and this can be annoying when you reply, if you don't include the link definition, it doesn't render correctly. Now that's interesting. I had assumed it would be less annoying than having them inline. Especially since people had already adopted a similar convention before we got Markdown support. I gave up on Thuderbird and went full-on with the web interface a couple of years ago, so I've had no view of the experience post-Markdown.
Re: Absence of isAllocator trait
On Saturday, 4 September 2021 at 19:43:27 UTC, Per Nordlöw wrote: Is there a reason for the absence of an `isAllocator` trait under `std.experimental.allocator`? I had ask a similar Q once and I've been told that (more or less): It's because the clients of an allocator should rather statically check for specific traits of an allocator, there are too many possible permutations of capabilities possible, not all can allocate and deallocate, not all can reallocate, and so on. actually I'm 100% sure that what you want is `isMallocator` and not `isAllocator` ;)
Re: Forum posting question ... how post a thread question with color syntax highlighting ??
On 9/5/21 9:18 PM, Ali Çehreli wrote: On 9/5/21 4:24 PM, someone wrote: > > For example; IIRC Ali's posts are always no-markdown. > That's because I've been using Thunderbird for mail and news for a long time now and unfortunately it is impossible to convince Thunderbird to add the necessary header field. (Vladimir has a recommendation where I can run a simply local server that augments Thunderbird's headers but I haven't tried it yet.) I should go back to using Emacs for news. I am pretty sure it will be configurable. Ali This is *exactly* how I do it. Though I have started creating an iopipe-based clone cause I wanted to see if I could do it. Unfortunately std.io is not mature enough. I plan to have a dub project so you can just `dub run thunderbirdmarkdown` and now you have a solution. And to answer someone's question, I think everyone is fine with markdown, they just don't always have the capability. I will note though, that some people use the mechanism for links that puts the link at the bottom of the post, and this can be annoying when you reply, if you don't include the link definition, it doesn't render correctly. -Steve
Re: Documentation generator is not working
On Monday, 6 September 2021 at 01:19:04 UTC, Ali Çehreli wrote: Yes, but it was meant to be a joke. Don't do that. :) Ha ha, okay :)