LNK2019 error from using a function pointer to core.bitop functions?
This member function of my struct uses a function pointer btx. When the line declaring the function pointer is present I get a LNK2019 error: unresolved external symbol. bool opIndexAssign(bool value, size_t[2] inds) { int function(size_t*, size_t) btx = (value) ? bts : btr; // error is here // other stuff here for (size_t i = startBitInd; i startWordBitDone; ++i) btx(bitArray[startWord], i); // other stuff here if (startWord != stopWord) for (size_t i = 0; i stopBitInd; ++i) btx(bitArray[stopWord], i); return value; } However, when I don't use the function pointer and instead call bts directly (as outlined below, the program compiles and links just fine. bool opIndexAssign(bool value, size_t[2] inds) { // other stuff here for (size_t i = startBitInd; i startWordBitDone; ++i) bts(bitArray[startWord], i); // other stuff here if (startWord != stopWord) for (size_t i = 0; i stopBitInd; ++i) bts(bitArray[stopWord], i); return value; } Any ideas how to fix this behavior? I was trying to use the function pointer so I wouldn't need to write essentially the same code block replacing bts with btr in if and else blocks Any help would be appreciated. Thanks
Re: Wait, what? What is AliasSeq?
On Thursday, 16 July 2015 at 00:49:29 UTC, Mike wrote: On Tuesday, 7 July 2015 at 21:15:40 UTC, Andrei Alexandrescu wrote: What happened? Why are we replacing a crappy term with another crappy term? Here's my interpretation of the current state of this as I read this thread 1. AliasSeq is no good as evident from the first post that started this thread 2. AliasList draws veto from decision makers due to list semantics in C++ 3. AliasTuple draws both support and disdain, but at least there's some support. Also, I volunteered to wordsmith the documentation on this, and I found myself a little dumbstruck yesterday trying to explain it. 4. AliasSplat uses a frivolous and slang term for the asterisk operator so is hard to take seriously, and like the other suggestions will require explanation. 5. Arguments isn't bad IMO, but it seems to draw disdain due to the fact that the construct in question may or may not be used for template arguments. You forgot Aliases, which also was suggested.
Re: Wait, what? What is AliasSeq?
On Thu, Jul 16, 2015 at 04:05:17AM +, Mike via Digitalmars-d wrote: On Thursday, 16 July 2015 at 00:49:29 UTC, Mike wrote: So, my asbestos underwear is on, and I ask if there is any support for the CompileTimeEntityList. I know it contains the 'L'-word, so if you prefer consider CompileTimeEntities. If the length bothers you, then consider CTEList (could also be interpreted as Compile-time element list, I suppose). I suppose CompileTimeTuple or CTTuple would be fine too, especially if we prefer to think of tuples as heterogeneous lists. Tuple was the original term used for this, and was also the term that started the whole debate because people thought it implied something that didn't fit in with how these things actually worked. It did not help that Phobos also defines a Tuple type, with more traditional tuple behaviour, that's based on this TypeTuple but different. However, the names being so similar, people were confusing and conflating the two, which led to all kinds of misunderstandings and confusion. If we're going to use any name with Tuple at all, we might as well just admit defeat and go back to the original TypeTuple after all, since nothing else seems to be any better. I think any successful name is going to have to be outside the usual suspects -- tuple, sequence, list, array, etc.. All of them have connotations that don't apply to this thing, and all of them lead the unwary to assume things about it that may not be correct. In fact, sequence so far is probably the least evil of all the alternatives, if only it weren't so long to spell out. I'm quite happy with AliasSeq, to be honest, though some people hate gratuitous abbreviations. I think it should just stay as AliasSeq, per Andrei's recent response. But in any case, if people think AliasSeq is not good enough, then we really have to think outside the box, because none of the usual candidates are going to work. AliasBeads (that I jokingly suggested), or AliasBraids, or ... various other silly names that kinda prove the point that we'd better just stick with AliasSeq and call it a day, instead of spending yet more time and energy on this long-dead horse. T -- That's not a bug; that's a feature!
Re: Wait, what? What is AliasSeq?
On Thursday, 16 July 2015 at 05:28:15 UTC, Ola Fosheim Grøstad wrote: std::forward_list Forget that one, that actually would be a single linked list… :P And in C++ you also have std::integer_sequence for compile time parameters. But I think sequence implies that everything has the same type...
Re: Wait, what? What is AliasSeq?
Oh, here is one more term you can consider: AliasPack In Python splatting is called unpacking (splat refers to the visual impression of the * operator and is inappropriate). C++ also have related use of the word pack: http://en.cppreference.com/w/cpp/language/parameter_pack So in C++ all of the terms list, sequence and pack can be used about parameter lists… but list is the general term: argument list, parameter list, initializer list etc…
Re: Wait, what? What is AliasSeq?
On Thursday, 16 July 2015 at 00:49:29 UTC, Mike wrote: 2. AliasList draws veto from decision makers due to list semantics in C++ Actually, AliasList is the most accurate term. List does not imply linked list in C++ or any other language I know of. C++ uses the term list for arguments. E.g: va_list std::forward_list std::initializer_list http://en.cppreference.com/mwiki/index.php?title=Special%3ASearchsearch=list (But keep it going, this thread is entertaining…)
Re: Wait, what? What is AliasSeq?
On Thursday, 16 July 2015 at 00:49:29 UTC, Mike wrote: So, my asbestos underwear is on, and I ask if there is any support for the CompileTimeEntityList. I know it contains the 'L'-word, so if you prefer consider CompileTimeEntities. If the length bothers you, then consider CTEList (could also be interpreted as Compile-time element list, I suppose). I suppose CompileTimeTuple or CTTuple would be fine too, especially if we prefer to think of tuples as heterogeneous lists.
Re: Profile Ouput
On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote: -- 4000 _Dmain _D4main6selectFZk 40002736471 4000 _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk -- Got it now. The 2736 and 471 are the call tree time and function call time, respectively, in *ticks*. They are converted to seconds then displayed as milliseconds int the table at the bottom of the file.
Re: Wait, what? What is AliasSeq?
On Thursday, 16 July 2015 at 05:51:01 UTC, Mike wrote: Sound familiar? I propose simply Pack. Or AliasListPack, AliasPackList, PackedAliasList… (I'd hate to see the thread die…)
Re: Wait, what? What is AliasSeq?
On Thursday, 16 July 2015 at 05:44:29 UTC, Ola Fosheim Grøstad wrote: C++ also have related use of the word pack: http://en.cppreference.com/w/cpp/language/parameter_pack Nice! From the description: A template parameter pack is a template parameter that accepts zero or more template arguments (non-types, types, or templates). A function parameter pack is a function parameter that accepts zero or more function arguments. A template with at least one parameter pack is called a variadic template. Sound familiar? I propose simply Pack. Mike
Re: Wait, what? What is AliasSeq?
On 07/16/2015 02:49 AM, Mike wrote: On Tuesday, 7 July 2015 at 21:15:40 UTC, Andrei Alexandrescu wrote: What happened? Why are we replacing a crappy term with another crappy term? Here's my interpretation of the current state of this as I read this thread 1. AliasSeq is no good as evident from the first post that started this thread Not at all evident. The only argument given in that post was not particularly valid.
Re: Weird behavior of this in a subclass, I think?
On Thursday, 16 July 2015 at 00:39:29 UTC, H. S. Teoh wrote: If you want to simulate overriding of class variables, you can use a @property method instead: class Animal { @property string voice() { return Wah!; } void speak() { writeln(voice); } } class Dog : Animal { override @property string voice() { return Whoof!; } } Alternatively: class Animal { protected string voice; void speak() { writeln(voice); } } class Dog : Animal { this() { voice = Whoof!; } }
Re: Weird behavior of this in a subclass, I think?
On Thursday, 16 July 2015 at 00:39:29 UTC, H. S. Teoh wrote: On Thu, Jul 16, 2015 at 12:18:30AM +, seashell86 via Digitalmars-d-learn wrote: [...] The reason is that class variables cannot be overridden, only class methods can. If you want to simulate overriding of class variables, you can use a @property method instead: class Animal { @property string voice() { return Wah!; } void speak() { writeln(voice); } } class Dog : Animal { override @property string voice() { return Whoof!; } } T Wow, a quick and thorough response! Thank you! I'm actually curious as to why this feature would not be in the language? Is it for performance reasons?
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Was there a good name suggested that wasn't vetoed by Walter or Andrei?
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 08:13:20 UTC, Paolo Invernizzi wrote: On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Yep, same feeling here At this point, I think that it's simply a question of which bad name we go with. None of them are particularly good, and there's a lot of disagreement about almost all of them - and if there's a lot of agreement, it's about how bad the name is, not how good it is. I'd be very surprised to ever get real agreement on this. There simply isn't a good name for it. And if Walter and Andrei like AliasTuple, it's probably going to stick (and Andrei does seem to like it; no idea about Walter). - Jonathan M Davis
Re: Last - but not least! - two DConf talks
On Tuesday, 14 July 2015 at 20:18:40 UTC, Brad Anderson wrote: On Monday, 13 July 2015 at 07:12:48 UTC, Atila Neves wrote: On Friday, 10 July 2015 at 18:33:04 UTC, Andrei Alexandrescu wrote: Spread the word! https://www.youtube.com/watch?v=bxSPCmwqgYs https://www.youtube.com/watch?v=jNQF3m5e2l0 Andrei https://www.reddit.com/r/programming/comments/3d3ooa/behaviourdriven_development_with_d_and_cucumber/ Also on HN, but as usual can't post the link. Atila Very cool techniques you've done there. I think you may have convinced me that Cucumber might be worth trying out. It does seem like you have to spend a lot of effort doing the plumbing to get it working (all the regexes) so I'm not completely sold but you've made it sound compelling enough to give it a whirl. Cucumber even gives you the regexes after you write the feature. All you have to do is write the code that should be run, really. Atila
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 07:22:36 UTC, Ola Fosheim Grøstad wrote: I use the GCC extensions/compiler hints… I think many include those in their C++ usage since Clang also support them. I think D would be better off by incorporating the same feature set (with a nicer syntax). The only thing I've found lacking in D compared to C++ is the extremely fragmented SIMD support. Some compiler hints that gcc offers are provided as language features in D(function attributes,) and the others are offered as vendor specific features(LDC, GDC both offer the equivalent of __builtin_expect for example.) GDC and LDC both respectively offer just as many tunables as their C++ counterparts, IMO. I'm not even sure if most people realize e.g, PGO works with D, or LTO, or the new LLVM/GCC sanitizers, etc.
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 08:29:52 UTC, Mike wrote: On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Was there a good name suggested that wasn't vetoed by Walter or Andrei? For me it was absolutely clear that picking a good name is impossible even through the previous discussion (~1 year ago) because existing semantics is a mess and breaking it is out of question. Thus more realistic criteria is name consistency with some bit of fact correctness. This was how original (Meta)List was chosen - being as bad as any other, it matched terms used by official compiler spec : http://dlang.org/template.html#TemplateParameterList http://dlang.org/template.html#TemplateArgumentList (and related docs) It is mostly irrelevant though (as long as it is not fundamentally misleading) - the whole issue is not about picking a single name but major cleanup sweeps through dlang.org and Phobos ensuring it is all on same terms and any possible abmiguity is clearly explained.
Re: Wait, what? What is AliasSeq?
Good to see another bad name merged in master ^_^
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Yep, same feeling here -- Paolo
Re: Where will D sit in the web service space?
On Monday, 13 July 2015 at 07:11:35 UTC, Ola Fosheim Grøstad wrote: Here's the deal: there is no such thing as a general purpose (system) language in the empirical sense. We might have been lead to believe that C or C++ were general purpose, but that only happend because there were no visible viable alternatives. C is more and more becoming a kernel/embedded language, C++ is more and more becoming a legacy/niche language. C++ is only a game dev language after you add various extensions (e.g. simd). It is only a number-crunching language after you add some other extensions. So you need a direction in the feature set towards an application area. Would you call python a gamedev language?
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 08:34:36 UTC, Kagamin wrote: Would you call python a gamedev language? No, Python is a scripting language.
[Issue 14702] struct epoll_event is packed incorrectly
https://issues.dlang.org/show_bug.cgi?id=14702 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/86cc2563e64fcb41d7e82fd5465272a9653130db Fix epoll_event alignment (issue 14702) https://github.com/D-Programming-Language/druntime/commit/8e99214e68f018c29fc53d8992dd591e275ffaed Merge pull request #1302 from tomerfiliba/patch-1 Fix epoll_event alignment (issue 14702) --
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 08:43:53 UTC, rsw0x wrote: I actuallly don't think low latency GCs are that great for gamedev because they not only have far lower throughput, but reduce the overall performance of the application. What I meant was: 1. Low latency GC are good for responsive web services that keep evolving over time. Makes development easy. 2. Linear typing is good for focused low memory usage/computational demanding web services. Makes memory related mistakes difficult/impossible. It will probably take years to work either alternative into D. Thus: 3. A simpler memory model (like C++) is more realistic, but not really attractive for a web service as it is less robust. Yet, many game devs are used to it. So maybe Weaselcat is right in saying that gamedev is the better sizeable market that D could aim for. That was my point ;) A high throughput GC that could complete in a few frames would probably be better, IMO. Yes, I think one only need a local GC for gameworld objects/NPCs/AI/scripting, so a GC could be limited to a specific graph/allocator right after execution when the memory is hot (programmer guaranteeing that there are no unregistered external pointers). It could indeed complete quickly for many game worlds.
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 09:01:25 UTC, Kagamin wrote: What's your estimation of a number of games written in python compared to a number of AAA shooters that can't live without realtime requirements? I have no estimate. For games it is used as a scripting language... Seriously, you cannot do anything in Python without C-counterparts. More games are written in Lua… doesn't make Lua a game dev language. It is still a scripting language. What point are you trying to make?
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Personally, I'm ok with the name AliasTuple Though I thought AliasSplat was good though... Also, this seems like the longest bikeshedding thread yet, even longer than the official bikeshedding thread a couple weeks ago!
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 07:59:49 UTC, wobbles wrote: On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Personally, I'm ok with the name AliasTuple Though I thought AliasSplat was good though... Well if you forget for a moment that it is neither tuple (per std.typecons.Tuple semantics) nor limited to aliases... :D Also, this seems like the longest bikeshedding thread yet, even longer than the official bikeshedding thread a couple weeks ago! AFAIR it is third thread like that on this topic in last 2 or 3 years.
[Issue 14725] std.getopt: improve error message for malformed arguments
https://issues.dlang.org/show_bug.cgi?id=14725 Robert Schadek rburn...@gmail.com changed: What|Removed |Added Status|NEW |ASSIGNED CC||rburn...@gmail.com --- Comment #1 from Robert Schadek rburn...@gmail.com --- I will work on that --
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ I don't mind AliasTuple, TypeTuple implied it could only contain types. The main issue is that the documentation for tuples is incredibly confusing.
[Issue 14724] std.getopt: config.required breaks --help
https://issues.dlang.org/show_bug.cgi?id=14724 --- Comment #2 from Robert Schadek rburn...@gmail.com --- https://github.com/D-Programming-Language/phobos/pull/3489 --
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On 7/15/2015 2:36 AM, Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= ola.fosheim.grostad+dl...@gmail.com wrote: You said it yourself that to get performance from C you need extensions, it's not provided by C semantics itself. No? I said I write cpu independent simd in my core performance oriented loop as a starting point. Whether I need to do that is debatable... but it ensures that data structures are designed to be simd friendly from the start. You also said: I use the GCC extensions/compiler hints… Being extensions, they aren't part of C itself.
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 06:57:36 UTC, Sebastiaan Koppe wrote: If D can do something cool with that, e.g. a web application framework where services sit behind a vibe-d web server, and where they can be easily developed, tested, deployed and upgraded - with 0 downtime - that would be great. Combine it with a knowledgeable community and some good practices (e.g. 12factor apps) and you can have a honey-pot. Ok, but then you need to focus on integration with at least one cloud service, like AWS and have a team that supports it on that cloud service. So I think that is starting in the wrong end. If you have a feature set that makes it easier to support products using D than Rust/Go/Java/C# in a specific domain, then some startup will pick it up to gain an advantage and build the next big thing. Then you get several frameworks more quickly because you have many hands. And the best ones survive. If you need a single excellent framework as the main feature... then you have lowered your odds. I don't think people care as much about the other stuff (gc, etc). I am now writing in Go, despite the language feeling odd and less familiar than D, because: 1. I want a statically typed language to deal with increased complexity (but not if it means more work overall than using Python, on more servers). 2. Google have announced that they have a low latency GC, so I feel confident that responsiveness is going to be OK and I don't have to deal with memory management at all. 3. Google are supporting it on their infrastructure, so I know it will interact well with Google Cloud and I don't have to worry about APIs. 4. There are web related 3rd party commercially supported libraries for interacting with commercial services. (Like Stripe for credit cards) I don't think vibe.d can build this eco system. I think you need a feature set that makes some startup want to build their _own_ public available framework using D for good PR. Docker is basically what made Microsoft embrace Go AFAIK.
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 00:28:47 UTC, Ola Fosheim Grøstad wrote: I am happy if I see that I have consistent 20% headroom, and I am not going to be happier by making my program faster... But then why optimizations would matter? If the program is fast, you won't improve it by improving performance by 2 times: it will remain fast, and if it's slow, it's probably an algorithmic complexity. You said it yourself that to get performance from C you need extensions, it's not provided by C semantics itself.
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 08:32:19 UTC, Kagamin wrote: On Wednesday, 15 July 2015 at 00:28:47 UTC, Ola Fosheim Grøstad wrote: I am happy if I see that I have consistent 20% headroom, and I am not going to be happier by making my program faster... But then why optimizations would matter? If the program is fast, you won't improve it by improving performance by 2 times: it will remain fast, and if it's slow, it's probably an algorithmic complexity. Ability to optimize later matters because I need to keep the deadline, or else the real time thread will be killed by the OS. If I miss the deadline occasionally, maybe I only need 10% improvement. I have many options. I can reduce fidelity in an audio application. I can put more work into integrating two loops into one loop and keep values in SIMD registers based on the number of SIMD register the particular CPU supports etc... What I don't want to do is restructure the entire dataset, so I put more work into memory layout than the initial loop. If the loop completes in time I'm good, if not, I put more work into it (or reluctantly reduce fidelity). You said it yourself that to get performance from C you need extensions, it's not provided by C semantics itself. No? I said I write cpu independent simd in my core performance oriented loop as a starting point. Whether I need to do that is debatable... but it ensures that data structures are designed to be simd friendly from the start.
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 09:15:46 UTC, rsw0x wrote: GDC and LDC both respectively offer just as many tunables as their C++ counterparts, IMO. I'm not even sure if most people realize e.g, PGO works with D, or LTO, or the new LLVM/GCC sanitizers, etc. That's interesting. I really don't have much incentive to look into it as I don't use D for anything commercial ATM, but if this is true, then D really would benefit from a visible tools-overview-tour on the website.
Re: Deal of the day: The D Programming Language @ Informit
It would be very nice if Andrei will find time to work on second edition, to update book with more actual language information. But the book is really cool!
Re: Beta D 2.068.0-b1
There was plan to include dub (and other tools) in DMD distrib. In what release it would be done?
Re: static class vs. static struct
In simple words, Singleton is a pattern and not a keyword. The Singleton pattern has several advantages over static classes. A singleton allows a class for which there is just one, persistent instance across the lifetime of an application. That means, it created a single instance and that instance (reference to that instance) can be passed as a parameter to other methods, and treated as a normal object. While a static class allows only static methods and and you cannot pass static class as parameter. More about. http://net-informations.com/faq/netfaq/singlestatic.htm Lee
Re: Where will D sit in the web service space?
On Tuesday, 14 July 2015 at 16:25:29 UTC, Ola Fosheim Grøstad wrote: I think the rest comes when you have the best feature set for a particular domain and a polished compiler/runtime. So yeah, maybe Game clients is the best bet, since you don't have to change the semantics too much (low latency GC and linear typing would take time to work in) and games benefits from C++/iOS interop. Indie games have low adoption threshold and could work as marketing. I actuallly don't think low latency GCs are that great for gamedev because they not only have far lower throughput, but reduce the overall performance of the application. They're great for e.g, networking where throughput and maximum performance really isn't a big deal but low latency is. A high throughput GC that could complete in a few frames would probably be better, IMO.
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 08:50:31 UTC, Ola Fosheim Grøstad wrote: No, Python is a scripting language. What's your estimation of a number of games written in python compared to a number of AAA shooters that can't live without realtime requirements?
[Issue 14724] std.getopt: config.required breaks --help
https://issues.dlang.org/show_bug.cgi?id=14724 Robert Schadek rburn...@gmail.com changed: What|Removed |Added CC||rburn...@gmail.com --- Comment #1 from Robert Schadek rburn...@gmail.com --- I will work on that --
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 08:05:59 UTC, Dicebot wrote: Well if you forget for a moment that it is neither tuple (per std.typecons.Tuple semantics) nor limited to aliases... :D My first association with 'Tuple' is that it's a heterogeneous structure, this is clearly a step up compared to other alternatives which were discussed such as 'Array' which traditionally are homogeneous. Thus I'm in favour of this name.
[Issue 14801] New: OS X installer not compatible with OS X 10.11
https://issues.dlang.org/show_bug.cgi?id=14801 Issue ID: 14801 Summary: OS X installer not compatible with OS X 10.11 Product: D Version: D2 Hardware: All OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: installer Assignee: nob...@puremagic.com Reporter: d...@me.com In the upcoming OS X 10.11 El Capitan Apple have new security policies. The result of this is that /usr/bin (and some other directories) are not writable, not even by root but /usr/local is available for developers [1]. The OS X installer should create the symlinks in /usr/local/bin instead of /usr/bin. /usr/local/bin is in the default PATH, so there should hopefully be no problems. [1] https://developer.apple.com/videos/wwdc/2015/?id=706 --
Re: Where will D sit in the web service space?
On Tuesday, 14 July 2015 at 16:25:29 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 14 July 2015 at 15:17:13 UTC, Sebastiaan Koppe wrote: On Sunday, 12 July 2015 at 12:14:31 UTC, Ola Fosheim Grøstad wrote: What do you think about the future for D in the web service space? What about this question: in 5 years from now what would be the reason D failed? It can't fail as long as Walter is having fun working on the compiler. :-) I meant in web services, not in general. A lack of decision making regarding picking an application domain that is large enough to sustain an ecosystem of libraries, and going 100% for honing the feature set towards that domain. Possible is not good enough. I get what you mean about having a focused direction so that any energy/time spend isn't scattered in all directions. I failed that in our last startup and we did alot of stuff, but in the end everything was half-finished. But I disagree about 'possible not being good enough'. In fact this property gives D the flexibility too accustom to pretty much anything. When I think about Web services and D, I don't think about just repeating what people do in other languages, but more about anticipating the future in web services. With my humble knowledge of the field that would be something with micro services and containers. If D can do something cool with that, e.g. a web application framework where services sit behind a vibe-d web server, and where they can be easily developed, tested, deployed and upgraded - with 0 downtime - that would be great. Combine it with a knowledgeable community and some good practices (e.g. 12factor apps) and you can have a honey-pot. I don't think people care as much about the other stuff (gc, etc).
Re: Covariant callback functions, or assigning base class members through a subclass reference
On 2015-07-14 17:28, Rene Zwanenburg wrote: Given the following code: class Base { alias CallbackType = void delegate(Base); CallbackType callback; void foo() { callback(this); } } class Derived : Base { } void main() { auto d = new Derived(); d.callback = (Derived d) { /* Do something */ } } Obviously this won't compile, since the callback function needs to have Base as parameter, not Derived. You can cast the delegate. It's probably unsafe but a simple example works. -- /Jacob Carlborg
Re: Beta D 2.068.0-b1
On 2015-07-12 02:29, Andrew Edwards wrote: Note, the current packaging format is incompatible with with OSX 10.11 (El Capitan). No previous release of DMD can be installed via the dmg files available on downloads.dlang.org or the ftp site (including dmd.2.068.0-b1). Reported an issue: https://issues.dlang.org/show_bug.cgi?id=14801 -- /Jacob Carlborg
Deal of the day: The D Programming Language @ Informit
Hi all! If you still don't have a copy of TDPL: Today it is the daily deal @ Informit. http://www.informit.com/deals/ Regards, Kai
Re: Polymorphic recursive class
On Wed, 15 Jul 2015 01:32:22 +, Morbid.Obesity wrote: love you, dear. signature.asc Description: PGP signature
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 04:39:13 UTC, Walter Bright wrote: Experience. Whenever I work with someone who tells me they don't need to profile because they know where their bottlenecks are, and I badger them into using a profiler, they turn out to be wrong. 100% of the time. Well, I don't do batch programming in C++. I only do interactive applications in C++ and most glitches are usually not about tuning performance, but about how things interact. Given that many interactive applications are ~90% idle you can improve responsiveness to a large extent by doing as little work as possible in the time critical hand-optimized region and push work over to the idle region (in the background). But that's all beside the point, which is that a programmer who is capable of writing top shelf performant programs in C++ can match or exceed that using D. All of the low level features of C++ are available in D. I use the GCC extensions/compiler hints… I think many include those in their C++ usage since Clang also support them. I think D would be better off by incorporating the same feature set (with a nicer syntax).
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 14:57:35 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 15 July 2015 at 13:04:55 UTC, Kagamin wrote: Though they are not as demanding interactive as shooters (maybe except for realtime interframe, but that's a video playback, not an editor). So what's true for shooters may be not true for other games. My point is if you care about market adoption you should look at numbers and should not overlook sizeable targetable parts of the market. Well, we are just talking about the language feature set, not that the frameworks should be built into the language. You have deadlines or you miss frames in graphics, you have deadlines in audio, you have memory subsystem requirements that are similar, you also want to tap into the coprocessor (which we now think of as GPU) for all kinds of application areas: 3D sculpting, photo editors, audio workstations, photon based tracers, real time ray tracers, 3D scan browsers… I don't think shooters are all that special. I think basically any interactive desktop application that you cannot do easily in Java is a candidate that could benefit from the same feature set. Two examples which I was involved with, but with C#. One is an application for live visualization of digital microscopes like these ones. http://www.leica-microsystems.com/products/digital-microscopes/ WPF application coded in C#, with bits of unsafe for image processing. C++ and Assembly were used for hot loops, basically some image filters. Also integration of legacy code from the previous Win32 generation of the software, which was being progressively replaced by C# code. Another is an application for processing data for biologic measurements and controlling the robots performing the experiment. https://www.thermoscientific.com/en/products/laboratory-robotics.html C++ was only used at the lowest level in the robot drivers and their firmware. Both links are just examples, my NDAs prevent me to say which products were really used, they are just examples of two fields with resource constraints that have been slowly moving to GC languages for their work. Assembly, C++ and C are being pushed down the stack to the hot paths that cannot be optimized any further by doing all sorts of tricks at C# level or driver related work. -- Paulo
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 15:54:17 UTC, Deadalnix wrote: This is not a popular word because this is not a popular construct to begin with. Yet this word is used to describe what we have here. Thanks to the wonderful ambiguity of natural languages, it's quite likely that a number of people will think splat is a verb because it's spelled identically to the noun. Those people would expect it to splat things, such as arrays etc. Which it doesn't, it's actually functions closer to identity than splat. Also newcomers looking for something which can handle undefined heterogeneous things, are not likely to search the documentation for Splat. Tuple is far likelier to be found.
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 18:21:10 UTC, Andrei Alexandrescu wrote: On 7/15/15 11:54 AM, Deadalnix wrote: That how I ended up with seq in the first place. I went to talk to everybody and sequence was what came up the most while not having people as opposed to it as list. Now I'm sorry I even started. I'd be happy to return to AliasSeq. -- Andrei LOL. Yeah. Naming discussions always seem to go like this. Sometimes, a better name does come out of it, but even if it does, there's just way too much in the way of discussion to wade through, and it's not generally the most pleasant either. Certainly, it's pretty much never intellectually stimulating. :| - Jonathan M Davis
Re: Wait, what? What is AliasSeq?
On Wed, Jul 15, 2015 at 02:21:54PM -0400, Andrei Alexandrescu via Digitalmars-d wrote: On 7/15/15 12:09 PM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Wednesday, 15 July 2015 at 15:49:43 UTC, Andrei Alexandrescu wrote: On 7/15/15 11:48 AM, Wyatt wrote: On Wednesday, 15 July 2015 at 15:28:11 UTC, Andrei Alexandrescu wrote: These google searches returned no meaningful results: Try: splat operator That doesn't come to mind when splat is used as a noun. -- Yeah, splat as a name for an auto-expanding thingy would be a novelty. Ruby for instance doesn't have anything like that, it has a splat _operator_ (asterisk) to expand a normal array, or conversely, capture several arguments in one parameter. So I'd say this is a strong argument against splat. -- Andrei joke Maybe we should call it AliasBeads. They have order, if you count them. Put lines of beads together, and they form a new line, so they autoexpand. I know of no other programming language that uses this term, so it's unique enough to cause people to think twice when using it. Plus, it allows for lame jokes about losing your beads when you do something wrong, or when the compiler has bugs that cause the beads to behave erratically. :-P /joke T -- Why are you blatanly misspelling blatant? -- Branden Robinson
Re: Wait, what? What is AliasSeq?
On 7/15/15 12:09 PM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Wednesday, 15 July 2015 at 15:49:43 UTC, Andrei Alexandrescu wrote: On 7/15/15 11:48 AM, Wyatt wrote: On Wednesday, 15 July 2015 at 15:28:11 UTC, Andrei Alexandrescu wrote: These google searches returned no meaningful results: Try: splat operator That doesn't come to mind when splat is used as a noun. -- Yeah, splat as a name for an auto-expanding thingy would be a novelty. Ruby for instance doesn't have anything like that, it has a splat _operator_ (asterisk) to expand a normal array, or conversely, capture several arguments in one parameter. So I'd say this is a strong argument against splat. -- Andrei
Re: Wait, what? What is AliasSeq?
On 7/15/15 11:54 AM, Deadalnix wrote: That how I ended up with seq in the first place. I went to talk to everybody and sequence was what came up the most while not having people as opposed to it as list. Now I'm sorry I even started. I'd be happy to return to AliasSeq. -- Andrei
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 10:54:04 UTC, Paulo Pinto wrote: On Wednesday, 15 July 2015 at 08:43:53 UTC, rsw0x wrote: [...] Games are much more than the code runs in a games console. Modern game development makes use of C#, Java and Erlang on the server side and engine tools. Just like in the 80's Basic, C and Pascal were used for tools while real game code was Assembly. I was referring only to the actual client code where C++ is typically used now.
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 10:55:19 UTC, rsw0x wrote: -pass-remarks-missed=pattern - Enable missed optimization remarks from passes whose name match the given regular expression from LDC's help output Good, that will encourage Walter to extend the D syntax with clean annotations! ;^) Something less ugly-looking than this: http://clang.llvm.org/docs/LanguageExtensions.html
Re: Wait, what? What is AliasSeq?
On 7/15/15 4:29 AM, Mike wrote: On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Was there a good name suggested that wasn't vetoed by Walter or Andrei? s/good name/name that I like/ FTFY Andrei
[Issue 14702] struct epoll_event is packed incorrectly
https://issues.dlang.org/show_bug.cgi?id=14702 Dmitry Olshansky dmitry.o...@gmail.com changed: What|Removed |Added Status|NEW |RESOLVED CC||dmitry.o...@gmail.com Resolution|--- |FIXED --
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
See http://llvm.org/docs/Vectorizers.html#diagnostics -Rpass=loop-vectorize identifies loops that were successfully vectorized. -Rpass-missed=loop-vectorize identifies loops that failed vectorization and indicates if vectorization was specified. -Rpass-analysis=loop-vectorize identifies the statements that caused vectorization to fail.
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 10:28:10 UTC, Ola Fosheim Grøstad wrote: See http://llvm.org/docs/Vectorizers.html#diagnostics -Rpass=loop-vectorize identifies loops that were successfully vectorized. -Rpass-missed=loop-vectorize identifies loops that failed vectorization and indicates if vectorization was specified. -Rpass-analysis=loop-vectorize identifies the statements that caused vectorization to fail. -pass-remarks=pattern - Enable optimization remarks from passes whose name match the given regular expression -pass-remarks-analysis=pattern- Enable optimization analysis remarks from passes whose name match the given regular expression -pass-remarks-missed=pattern - Enable missed optimization remarks from passes whose name match the given regular expression from LDC's help output
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 10:57:55 UTC, rsw0x wrote: On Wednesday, 15 July 2015 at 10:54:04 UTC, Paulo Pinto wrote: On Wednesday, 15 July 2015 at 08:43:53 UTC, rsw0x wrote: [...] Games are much more than the code runs in a games console. Modern game development makes use of C#, Java and Erlang on the server side and engine tools. Just like in the 80's Basic, C and Pascal were used for tools while real game code was Assembly. I was referring only to the actual client code where C++ is typically used now. Ah ok, sorry for the noise then.
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 11:49:46 UTC, Andrei Alexandrescu wrote: On 7/15/15 3:50 AM, Dicebot wrote: Good to see another bad name merged in master ^_^ So now we're at AliasTuple? -- Andrei Well at least I have noticed notification about that being merged into Phobos master in my mailbox. I was not following this thread itself much.
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 08:43:53 UTC, rsw0x wrote: On Tuesday, 14 July 2015 at 16:25:29 UTC, Ola Fosheim Grøstad wrote: I think the rest comes when you have the best feature set for a particular domain and a polished compiler/runtime. So yeah, maybe Game clients is the best bet, since you don't have to change the semantics too much (low latency GC and linear typing would take time to work in) and games benefits from C++/iOS interop. Indie games have low adoption threshold and could work as marketing. I actuallly don't think low latency GCs are that great for gamedev because they not only have far lower throughput, but reduce the overall performance of the application. They're great for e.g, networking where throughput and maximum performance really isn't a big deal but low latency is. A high throughput GC that could complete in a few frames would probably be better, IMO. Games are much more than the code runs in a games console. Modern game development makes use of C#, Java and Erlang on the server side and engine tools. Just like in the 80's Basic, C and Pascal were used for tools while real game code was Assembly.
Re: Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++
On Wednesday, 15 July 2015 at 09:52:28 UTC, Walter Bright wrote: You also said: I use the GCC extensions/compiler hints… Being extensions, they aren't part of C itself. Yes, I use them in hot spots, because I think it makes sense to explicitly vectorize a loop if I make it a requirement. The annotations document what I want from the loop. I don't have to, I could recompile until the asm looks right. But that is more tedium and code changes down the road can affect it.
Re: Understanding Safety of Function Pointers vs. Addresses of Functions
On Tuesday, 14 July 2015 at 17:24:41 UTC, anonymous wrote: This fails with Error: None of the overloads of 'cos' are callable using argument types (int[]). The problem is that template mixins cannot add to existing overload sets. The spec says: If the name of a declaration in a mixin is the same as a declaration in the surrounding scope, the surrounding declaration overrides the mixin one [1]. That means, the `cos` from `alias cos = std.math.cos;` completely overrides the one from `mixin t!();`. I guess this is a measure against function hijacking again. I'm not sure if it's supposed to work like it does when the alias is removed, two implicitly imported/generated symbols forming an overload set. But I can't immediately see a problem with it either. [1] http://dlang.org/template-mixin.html - see Mixin Scope Now - is there a way to rewrite my code without mixins?
Re: Wait, what? What is AliasSeq?
On 7/15/15 3:50 AM, Dicebot wrote: Good to see another bad name merged in master ^_^ So now we're at AliasTuple? -- Andrei
Re: Profile Ouput
On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote: -- 4000 _Dmain _D4main6selectFZk 40002736471 4000 _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk -- OK, I've finally realized that the top part of trace.log is an inverted (with main at the bottom) call tree. I've got everything now except that 2736 and 471 on the second line. Anyone?
Re: Wait, what? What is AliasSeq?
On 7/15/15 7:39 AM, Mike wrote: FYI, I didn't expect the AliasTuple PR to be merged so quickly. Me neither. Since the bikeshedding gates have been opened, let the flood subside a little before taking action. -- Andrei
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 12:30:39 UTC, Kagamin wrote: You're probably extending shooters stereotypes to other genres of games. But then it would matter how sizeable is shooters market compared to other genres of games, which don't need C as badly. It's true, that you can't do anything without C, but it's true for all applications, not just games. When I say game dev, I actually mean engines for demanding interactive audio-visual applications for mobile and desktop. That could be custom sound editors, video editors, paint programs, computer games, art installations, information kiosk applications, interactive simulations, educational software etc.
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 09:09:57 UTC, Ola Fosheim Grøstad wrote: I have no estimate. For games it is used as a scripting language... Seriously, you cannot do anything in Python without C-counterparts. More games are written in Lua… doesn't make Lua a game dev language. It is still a scripting language. What point are you trying to make? You're probably extending shooters stereotypes to other genres of games. But then it would matter how sizeable is shooters market compared to other genres of games, which don't need C as badly. It's true, that you can't do anything without C, but it's true for all applications, not just games.
Re: Last - but not least! - two DConf talks
On 2015-07-13 09:12, Atila Neves wrote: https://www.reddit.com/r/programming/comments/3d3ooa/behaviourdriven_development_with_d_and_cucumber/ Also on HN, but as usual can't post the link. Atila Really great talk. We're using Cucumber (or rather a similar tool called Turnip) a lot at work and I was using the standard version at my previous work. A couple of things I don't like with the standard Cucumber are: 1. Regular expressions used for defining steps. Using actual regular expression is seldom needed, most of the time only a string is needed. Turnip uses strings with variable support, that is, any word prefix with a colon will be assumed to be a variable and passed to the block as an argument. What can easily happen with regular expression is the steps become too generic and try to do too much. This can of course happen with strings as well but it's less likely because a string is more limited on what it can match. 2. All steps are global. If nothing has changed recently all steps are available for all features/scenarios. This becomes a problem when you have similar steps but with different implementation, or rather the data is different. Which easily happens when you have a lot of features files. What happened to us was that to be able to share data between the steps a global associative array was used. This also caused a lot more data to be present in the feature file than we would have liked. Like identifiers to find the data in the associative array. Everything had dependencies on everything else can became a big mess. We have solved this with a heavily modified version of Turnip. Turnip uses the Gherkin feature files but is using RSpec as the test runner. We have modified Turnip so each feature is mapped to a module/namespace, each scenario is mapped a nested module, which is then included in the anonymous class that RSpec creates. Each step is mapped to a method in that anonymous class. Now we were able to do two things, have steps that are local to a scenario, without causing any conflicts and share data between the steps using instance variables. This resulted a completely different thinking in how to write feature files and how to implement them. We were also able to remove a lot of unnecessary data from the feature files. -- /Jacob Carlborg
Re: Last - but not least! - two DConf talks
On 2015-07-13 09:12, Atila Neves wrote: https://www.reddit.com/r/programming/comments/3d3ooa/behaviourdriven_development_with_d_and_cucumber/ Also on HN, but as usual can't post the link. The comment about not having to name the steps. One way to do that could be something like this: step(foo bar, { // step implementation }); There are two problems with that: 1. D doesn't support module level code like this. Which could be solved by either using a unit test block, a module constructor or some other function the framework knows about to call. 2. That syntax is not as nice as in Ruby. It would be really nice if the following could be supported: step(foo bar) { // step implementation } A trailing delegate syntax, where the delegate is passed after the regular argument list. -- /Jacob Carlborg
[Issue 14328] The terms lvalue and rvalue should be added to the glossary
https://issues.dlang.org/show_bug.cgi?id=14328 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/c8ce0b882ba2b6ec0522a28746c448d337ac5b8b Fix issue 14328 https://github.com/D-Programming-Language/dlang.org/commit/eb9635f66087761793d863b836e3677b93b20289 Merge pull request #983 from nomad-software/issue_14328 Issue 14328 - The terms lvalue and rvalue should be added to the glossary --
Re: Wait, what? What is AliasSeq?
On 2015-07-15 18:09, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Yeah, splat as a name for an auto-expanding thingy would be a novelty. Ruby for instance doesn't have anything like that, it has a splat _operator_ (asterisk) to expand a normal array, or conversely, capture several arguments in one parameter. I'm not sure what should count as auto-expanding, but this works in Ruby: a, b = [1, 2] No extra operator is required in this case. -- /Jacob Carlborg
Re: Why aren't you using D at work?
On 07/15/2015 12:06 PM, Poyeyo wrote: Lack of a complete MySQL driver. No DECIMAL support that I know of. Lack of MySQL support in vibe.d. Please file any issues you may have with mysql-native here: https://github.com/mysql-d/mysql-native Or ping any existing issues that you may need to ping.
Re: Deal of the day: The D Programming Language @ Informit
A Bargain at twice the price!! Really. It cleared up a lot of things for me. Though I occasionally see some out of date info, I find it an invaluable resource to understand the language.
Auto-Vectorization and array/vector operations
I was trying to show someone how awesome Dlang was earlier, and how the vector operations are expected to take advantage of the CPU vector instructions, and was dumbstruck when dmd and gdc both failed to auto-vectorize a simple case. I've stripped it down to the bare minimum and loaded the example on the interactive compiler: http://asm.dlang.org/#%7B%22version%22%3A3%2C%22filterAsm%22%3A%7B%7D%2C%22compilers%22%3A%5B%7B%22sourcez%22%3A%22JYWwDg9gTgLgBAY2gUwHQGdQBMDcAoPAMwBsIBDGAbQCYBWANgF05kAPM8Y5AQQAoTyVOkzhkANHAEUaDZgCMAlHgDeeOJNLThzBPnUB6fXCjJ0AV2Ix0cYADs45uenRrElZgF5R7uAFo4cu56xsgwZlD2ungAvgRSQrIs7JzIAEL8mgki4hqCMiKKKq7xAByUAMzUjABuZHBeCGToMBmCZZWMCmTBpRVV1XL1iE0tvR0Kcj2Z7f1R6q6GIeaW1nYOZnJgLurVCD5etT7%2BA0EE6iZhEcPNrVqyCrv40UAAA%3D%22%2C%22compiler%22%3A%22dmd2067%22%2C%22options%22%3A%22-O%20-release%20-inline%20-boundscheck%3Doff%22%7D%5D%7D The reference documentation for arrays says: Implementation note: many of the more common vector operations are expected to take advantage of any vector math instructions available on the target computer. Does this mean that while compilers are expected to take advantage of them, they currently do not, even when they have proper alignment? I haven't tried LDC yet, so maybe LDC does perform auto-vectorization and I should attempt to use LDC if I plan on using vector ops a lot? import core.simd; float[256] exampleA(float[256] a, float[256] b) { float[256] c; // results in subss (scalar instruction) c[] = a[] - b[]; return c; } float[256] exampleB(float[256] a, float[256] b) { float8[32]va = cast(float8[32])a; float8[32]vb = cast(float8[32])b; float8[32]vc; // results in subps (vector instruction) vc[] = va[] - vb[]; return cast(float[256])vc; }
Re: Template function that accept strings and array of strings
On Wednesday, 15 July 2015 at 21:57:50 UTC, badlink wrote: Hello, I can't figure how to write a template function that accept either strings or array of strings. This is my current code: bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(typeof(T) == char) || (isArray!T is(typeof(T[]) == char))) {...} I used const(T)[] because I'd like to accept immutable and mutable strings. But calling it with an immutable string generate this error: Error: template cache.MetadataCache.hasItemParent cannot deduce function from argument types !()(string, string), candidates are: cache.MetadataCache.hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(typeof(T) == char)) Any suggestions ? T is already a type, so typeof(T) is an error, which makes the constraint fail. Try hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(T == char) || is (T == char[])) at least I think that's what you meant. typeof(anything[]) will never == char.
Re: Template function that accept strings and array of strings
On Wednesday, 15 July 2015 at 21:57:50 UTC, badlink wrote: Hello, I can't figure how to write a template function that accept either strings or array of strings. This is my current code: bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(typeof(T) == char) || (isArray!T is(typeof(T[]) == char))) {...} I used const(T)[] because I'd like to accept immutable and mutable strings. But calling it with an immutable string generate this error: Error: template cache.MetadataCache.hasItemParent cannot deduce function from argument types !()(string, string), candidates are: cache.MetadataCache.hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(typeof(T) == char)) Any suggestions ? T is already a type, you don't need to typeof() it. This should work: bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(T == char) || (isArray!T is(ElementType!T == char)))
Re: Profile Ouput
On Wednesday, 15 July 2015 at 11:47:53 UTC, Mike Parker wrote: On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote: -- 4000 _Dmain _D4main6selectFZk 40002736471 4000 _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk -- OK, I've finally realized that the top part of trace.log is an inverted (with main at the bottom) call tree. I've got everything now except that 2736 and 471 on the second line. Anyone? I've been confused by this too. The only thing I can find is this http://www.digitalmars.com/ctg/trace.html I think it would be cool to write something that takes the output and puts it in a prettier format.
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 18:21:10 UTC, Andrei Alexandrescu wrote: On 7/15/15 11:54 AM, Deadalnix wrote: That how I ended up with seq in the first place. I went to talk to everybody and sequence was what came up the most while not having people as opposed to it as list. Now I'm sorry I even started. I'd be happy to return to AliasSeq. -- Andrei Luckily we have 2 people that can just decide. I reckon at this stage yourself and Walter should just pick the name ye prefer best and go with it. The democratic approach, I feel anyway, hasn't worked in this case... (Doesn't mean it wont in future!!)
Re: Auto-Vectorization and array/vector operations
On Wednesday, 15 July 2015 at 22:42:05 UTC, Steven wrote: I was trying to show someone how awesome Dlang was earlier, and how the vector operations are expected to take advantage of the CPU vector instructions, and was dumbstruck when dmd and gdc both failed to auto-vectorize a simple case. I've stripped it down to the bare minimum and loaded the example on the interactive compiler: I'm not sure how the compilers handle auto-vectorization, but I found http://dconf.org/2013/talks/evans_2.html informative. It recommends not casting between float and simd types.
Weird behavior of this in a subclass, I think?
So I've been mostly just toying around with D as it seems like it will end up being a strong language for game development both now and even moreso in the future. That being said, I'm perplexed by using this code and not receiving the result I would imagine. Here is the source code of a basic sandbox.d file: import std.stdio; class Animal { string voice; void speak() { writeln(this.voice); } } class Dog : Animal { string voice = Whoof!; } int main() { auto a = new Animal(); auto d = new Dog(); a.speak(); // Prints d.speak(); // Prints instead of Whoof! return 0; } I know that C++ behaves this way. However, Dlang impresses me by having a very no duh approach to things where this type of example seems very no duh. Anyways, please be gentle as I am hardly what most would consider a skilled programmer and, as such, was something I wanted to bounce off the pros :)
Re: Weird behavior of this in a subclass, I think?
On Thu, Jul 16, 2015 at 12:18:30AM +, seashell86 via Digitalmars-d-learn wrote: So I've been mostly just toying around with D as it seems like it will end up being a strong language for game development both now and even moreso in the future. That being said, I'm perplexed by using this code and not receiving the result I would imagine. Here is the source code of a basic sandbox.d file: import std.stdio; class Animal { string voice; void speak() { writeln(this.voice); } } class Dog : Animal { string voice = Whoof!; } int main() { auto a = new Animal(); auto d = new Dog(); a.speak(); // Prints d.speak(); // Prints instead of Whoof! return 0; } I know that C++ behaves this way. However, Dlang impresses me by having a very no duh approach to things where this type of example seems very no duh. Anyways, please be gentle as I am hardly what most would consider a skilled programmer and, as such, was something I wanted to bounce off the pros :) The reason is that class variables cannot be overridden, only class methods can. If you want to simulate overriding of class variables, you can use a @property method instead: class Animal { @property string voice() { return Wah!; } void speak() { writeln(voice); } } class Dog : Animal { override @property string voice() { return Whoof!; } } T -- Indifference will certainly be the downfall of mankind, but who cares? -- Miquel van Smoorenburg
Re: Profile Ouput
On Wednesday, 15 July 2015 at 18:02:11 UTC, jmh530 wrote: I've been confused by this too. The only thing I can find is this http://www.digitalmars.com/ctg/trace.html I think it would be cool to write something that takes the output and puts it in a prettier format. Yeah, I eventually stumbled on to that, but it unfortunately tells me nothing I don't already know. I suppose I'll just email Walter and ask him.
Re: Wait, what? What is AliasSeq?
On Tuesday, 7 July 2015 at 21:15:40 UTC, Andrei Alexandrescu wrote: What happened? Why are we replacing a crappy term with another crappy term? Here's my interpretation of the current state of this as I read this thread 1. AliasSeq is no good as evident from the first post that started this thread 2. AliasList draws veto from decision makers due to list semantics in C++ 3. AliasTuple draws both support and disdain, but at least there's some support. Also, I volunteered to wordsmith the documentation on this, and I found myself a little dumbstruck yesterday trying to explain it. 4. AliasSplat uses a frivolous and slang term for the asterisk operator so is hard to take seriously, and like the other suggestions will require explanation. 5. Arguments isn't bad IMO, but it seems to draw disdain due to the fact that the construct in question may or may not be used for template arguments. So, my asbestos underwear is on, and I ask if there is any support for the CompileTimeEntityList. I know it contains the 'L'-word, so if you prefer consider CompileTimeEntities. If the length bothers you, then consider CTEList (could also be interpreted as Compile-time element list, I suppose). I have one other suggestion, but I'd like to see how this goes first. Given the current state of things, it appears that remaining silent or voicing disapproval without a viable suggestion is an implicit vote for AliasTuple. Mike
Template function that accept strings and array of strings
Hello, I can't figure how to write a template function that accept either strings or array of strings. This is my current code: bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(typeof(T) == char) || (isArray!T is(typeof(T[]) == char))) {...} I used const(T)[] because I'd like to accept immutable and mutable strings. But calling it with an immutable string generate this error: Error: template cache.MetadataCache.hasItemParent cannot deduce function from argument types !()(string, string), candidates are: cache.MetadataCache.hasItemParent(T)(const(char)[] itemId, const(T)[] parentId) if (is(typeof(T) == char)) Any suggestions ?
[Issue 14802] New: Template argument deduction depends on order of arguments
https://issues.dlang.org/show_bug.cgi?id=14802 Issue ID: 14802 Summary: Template argument deduction depends on order of arguments Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: timokhin...@gmail.com Template argument deduction from several identical parameters may depend on order of the arguments. test.d void f(T)(T x, T y) { pragma(msg, T); } void main() { f(1.0, 1.0f); f(1.0f, 1.0); } $ dmd test.d float double --
Re: Wait, what? What is AliasSeq?
On 07/15/2015 05:35 PM, Dicebot wrote: On Wednesday, 15 July 2015 at 15:29:25 UTC, Andrei Alexandrescu wrote: It doesn't confuse me. We have type tuples and expression tuples defined in the spec. An alias tuple can have both expressions and types. It's not that confusing. What was confusing is that a TypeTuple was not a type tuple as defined in the spec. I agree. Andrei I want to point out that statement an alias tuple can have both expressions and types is somewhat between imprecise and just wrong with current compiler implementation. `X!(42, int, foo)` doesn't hold aliases to value, type and symbol (assuming X(T...)) - it does hold actual value and type, with only symbol being aliased. Actual alias tuple would be defined as `X(alias a, alias b, alias c)` and is somewhat different thing. You may want to ignore that difference for simplicity sake but it needs to be explicitly acknowledged. It should instead be acknowledged that there /should/ be no difference in what three things can be passed to X(T...) and X(alias a, alias b, alias c). The X(T...) if(T.length==k) pattern is ridiculous.
Re: Understanding Safety of Function Pointers vs. Addresses of Functions
On Wednesday, 15 July 2015 at 11:45:00 UTC, Laeeth Isharc wrote: Now - is there a way to rewrite my code without mixins? Not sure that is possible. It would be interesting if someone could figure it out though. I'm more focused on making the givemeabettername a bit more general. Someone above had sort of asked why bother for the simple case. True enough, but if I can write something generic enough to work on a wide variety of function types, then I would consider it a win. E.g., below. template givemeabettername(alias fun) { static if (arity!fun == 1) { T givemeabettername(T)(T x) if (isDynamicArray!(T)) { return x.map!fun.array; } T givemeabettername(T)(T x) if (isStaticArray!(T)) { T result = x.dup; foreach(ref elem; result) { elem = fun(elem); } return result; } } }
Re: Wait, what? What is AliasSeq?
On 07/15/2015 08:21 PM, Andrei Alexandrescu wrote: On 7/15/15 11:54 AM, Deadalnix wrote: That how I ended up with seq in the first place. I went to talk to everybody and sequence was what came up the most while not having people as opposed to it as list. Now I'm sorry I even started. I'd be happy to return to AliasSeq. -- Andrei +1.
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 09:32:07 UTC, Dicebot wrote: This was how original (Meta)List was chosen - being as bad as any other, it matched terms used by official compiler spec : http://dlang.org/template.html#TemplateParameterList http://dlang.org/template.html#TemplateArgumentList (and related docs) It is mostly irrelevant though (as long as it is not fundamentally misleading) - the whole issue is not about picking a single name but major cleanup sweeps through dlang.org and Phobos ensuring it is all on same terms and any possible abmiguity is clearly explained. Your comment resonates with me. Would TemplateArguments, TemplateArgs, or TemplateArgList make things any better in your opinion? FYI, I didn't expect the AliasTuple PR to be merged so quickly. If that's as good as it gets, so be it, but I'd like to bring this discussion to a amicable end, and I don't mind submitting a couple more alternate PRs if will help those who have to make the final judgment call and bring this issue to a close. Mike
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 11:50:43 UTC, Andrei Alexandrescu wrote: On 7/15/15 4:29 AM, Mike wrote: On Wednesday, 15 July 2015 at 07:50:46 UTC, Dicebot wrote: Good to see another bad name merged in master ^_^ Was there a good name suggested that wasn't vetoed by Walter or Andrei? s/good name/name that I like/ What makes a good name good? Some people thought 'splat' sounded ridiculous, i.e., they didn't like it, but its use in PHP, Ruby, and other scripting operators, where it's really quite similar to its use in D, make it a 'good' candidate IMO. It doesn't have numerous alternative meanings in CS, like List/Tuple/Sequence, and its coinage is relatively recent, so recent that the Wiki entry https://en.wikipedia.org/wiki/Splat doesn't refer to its use as a term in programming yet. It's also short. I liked 'Seq', because it is a bit ambiguous, unlike 'Tuple', which has the same meaning in many popular languages, but by most criteria 'Splat' is better.
Re: Wait, what? What is AliasSeq?
On 15-Jul-2015 16:32, Deadalnix wrote: On Wednesday, 15 July 2015 at 11:49:46 UTC, Andrei Alexandrescu wrote: On 7/15/15 3:50 AM, Dicebot wrote: Good to see another bad name merged in master ^_^ So now we're at AliasTuple? -- Andrei Please go for splat. It turns out it is used by functional guy, in various scripting languages and in the compiler backend communities. The thing we are trying to name is a splat. Seems like the best option w.r.t. naming things what they are. Silly or not silly it's established and not confusing. -- Dmitry Olshansky
Re: Where will D sit in the web service space?
On Wednesday, 15 July 2015 at 06:57:36 UTC, Sebastiaan Koppe wrote: I don't think people care as much about the other stuff (gc, etc). I think a lot of people do care about GC, and the D story there (problematic conservative GC used in libraries, with exceptions, etc.) is worse than the Go story (precise, concurrent, low latency GC with improvements planned) or the Rust story (no GC, like C++ but much safer). There was some noise about a precise GC for D two years ago, with one poster claiming he'd write one over a summer, but nothing happened. Then the Higgs author posted her problems with GC here http://pointersgonewild.com/2014/09/09/ds-garbage-collector-problem/ and there is still this perception in the world that GC is a problem with D.
Casting random type to random struct - is this a bug?
struct S { int a, b; } auto s = cast(S)10; //compiles and sets s.a to 10. It works also for any other type, if the structure contains a member of that type in the first position. Is this normal behaviour?
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 15:28:11 UTC, Andrei Alexandrescu wrote: These google searches returned no meaningful results: Try: splat operator Let's not inflate each new name idea to alleged popularity it doesn't really enjoy. Having slept on it, I like splat because it IS relatively new as a named concept in our field. Language is arbitrary, so we can do this and anyone confused can look it up. There will be no turning back. Precisely. -Wyatt
Re: Wait, what? What is AliasSeq?
On 7/15/15 11:48 AM, Wyatt wrote: On Wednesday, 15 July 2015 at 15:28:11 UTC, Andrei Alexandrescu wrote: These google searches returned no meaningful results: Try: splat operator That doesn't come to mind when splat is used as a noun. -- Andrei
Re: Wait, what? What is AliasSeq?
On Wednesday, 15 July 2015 at 15:28:11 UTC, Andrei Alexandrescu wrote: On 7/15/15 9:32 AM, Deadalnix wrote: On Wednesday, 15 July 2015 at 11:49:46 UTC, Andrei Alexandrescu wrote: On 7/15/15 3:50 AM, Dicebot wrote: Good to see another bad name merged in master ^_^ So now we're at AliasTuple? -- Andrei Please go for splat. It turns out it is used by functional guy, in various scripting languages and in the compiler backend communities. The thing we are trying to name is a splat. These google searches returned no meaningful results: splat splat data structure splat type splat computer science I did find a few relevant results with: splat functional languages splat scripting languages Let's not inflate each new name idea to alleged popularity it doesn't really enjoy. I'm not inflating popularity (you'll have hard time quoting me doing fo, so please don't. Words have precise meaning). This is not a popular word because this is not a popular construct to begin with. Yet this word is used to describe what we have here. A newcomer would have either no expectation of what this construct is because he doesn't know the word (still better than tuple or list that come with the wrong expectation) or know the word and know what to expect. Also, I don't have any veto, but if I had one, tuple would get it. I've been hanging around for a while and seen so many being confused by d tuples that persisting in that direction would be a religious decision. For this coming release we've opened the naming to a somewhat democratic process. Walter and my plan was to let everyone discuss, then approve the consensus. We jokingly/worriedly remarked that all the cries but we have consensus on a different name! when there existed a perception of names being imposed will instantly go away. And so it did. We won't be able to make progress if ten folks have eleven ideas about what's needed. People, choose AliasSeq, AliasTuple, or whatever the heck most of us agree upon, but let's just choose once and for good. There will be no turning back. Andrei That how I ended up with seq in the first place. I went to talk to everybody and sequence was what came up the most while not having people as opposed to it as list. What the majority come up with is different from everyone's first choice (seq isn't even my first choice). On the other hand, the recent change looks like a coup.