Re: Is betterC affect to compile time?

2019-07-25 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 25 July 2019 at 12:46:48 UTC, Oleg B wrote: On Thursday, 25 July 2019 at 12:34:15 UTC, rikki cattermole wrote: Those restrictions don't stop at runtime. It's vary sad. What reason for such restrictions? It's fundamental idea or temporary implementation? Yes it is very sad. It

Re: Any 3D Game or Engine with examples/demos which just work (compile&run) out of the box on linux ?

2019-10-20 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 18 October 2019 at 06:11:37 UTC, Ferhat Kurtulmuş wrote: On Friday, 18 October 2019 at 05:52:19 UTC, Prokop Hapala wrote: Already >1 year I consider to move from C++ to Dlang or to Rust in my hobby game development (mostly based on physical simulations https://github.com/ProkopHapal

Re: Thin UTF8 string wrapper

2019-12-06 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 6 December 2019 at 16:48:21 UTC, Joseph Rushton Wakeling wrote: Hello folks, I have a use-case that involves wanting to create a thin struct wrapper of underlying string data (the idea is to have a type that guarantees that the string has certain desirable properties). The string

dmd -nodefaultlibs?

2019-05-21 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to prevent dmd from adding any default libraries to its linker command? Something equivalent to "-nodefaultlibs" from gcc? https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html I'd still like to use the dmd.conf file, so I don't want to use "-conf="

Re: make C is scriptable like D

2019-06-20 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 20 June 2019 at 06:20:17 UTC, dangbinghoo wrote: hi there, a funny thing: $ cat rgcc #!/bin/sh cf=$@ mycf=__`echo $cf|xargs basename` cat $cf | sed '1d' > ${mycf} gcc ${mycf} -o a.out rm ${mycf} ./a.out $ cat test.c #!/home/user/rgcc #include int

Re: Mixin mangled name

2019-07-01 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 1 July 2019 at 19:40:09 UTC, Andrey wrote: Hello, Is it possible to mixin in code a mangled name of some entity so that compiler didn't emit undefined symbol error? For example mangled function name or template parameter? If you've got undefined symbol "foo", you could just add thi

Re: Building (and including libraries) without dub

2017-08-26 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 26 August 2017 at 12:45:31 UTC, Adam D. Ruppe wrote: On Saturday, 26 August 2017 at 09:03:03 UTC, Hasen Judy wrote: Building simple programs without dub is easy, just pass a list of .d source files to `dmd` or `ldc2`. What if I want to include a 3rd party library? It is also eas

DMD Test Suite Windows

2017-12-18 Thread Jonathan Marler via Digitalmars-d-learn
Trying to run the dmd test suite on windows, looks like Digital Mars "make" doesn't work with the Makefile, I tried Gnu Make 3.81 but no luck with that either. Anyone know which version of make it is supposed to work with on windows? Is it supposed to work on windows at all?

core.sys.windows so lean?

2016-06-06 Thread Jonathan Marler via Digitalmars-d-learn
I'm writing some platform specific D code and I've found that what the druntime exposes for the windows platform is pretty lean. I'm guessing that the purpose of the druntime version of the windows api is to implement the minimum required to support the windows platform and not meant to be a f

Re: core.sys.windows so lean?

2016-06-06 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:13:48 UTC, Vladimir Panteleev wrote: On Monday, 6 June 2016 at 16:04:30 UTC, Jonathan Marler wrote: I'm writing some platform specific D code and I've found that what the druntime exposes for the windows platform is pretty lean. I'm guessing that the purpose of the

Re: core.sys.windows so lean?

2016-06-06 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 6 June 2016 at 17:11:44 UTC, Vladimir Panteleev wrote: On Monday, 6 June 2016 at 16:51:20 UTC, Jonathan Marler wrote: Hmmm...it seems to be missing quite alot though. You could've mentioned you meant just the winsock modules. They have not been brought over because they were not e

dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
I've decided to write a web application using vibe and was shocked to see that dlang.org was using apache. Should I be scared that even after this long, the official D website doesn't rely on its own web tools?

Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 13:32:00 UTC, Mike Parker wrote: Why would we change over when Apache is working quite happily to serve up static content? I've heard that same argument as the reason people don't use the D language. Why would I change over to D when C/C++ is working quite happil

Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 14:30:53 UTC, Adam D. Ruppe wrote: These servers tend to be very efficient at front end tasks like load balancing, static file serving and cache management, standards compliance (including automatically up/down grading HTTP versions or TLS requirements), management,

Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 14:43:35 UTC, Mike Parker wrote: Really? I just don't see it as that big of a deal. Again, three subdomains are using D right now. So it's not like it's not being used at all. Moving the website to D just hasn't been a priority (nor should it be, IMO). Anyone in the

Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:51:58 UTC, Adam D. Ruppe wrote: On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad wrote: The forum-index http header report: Server:nginx/1.4.6 (Ubuntu) People check out stuff like that. Yeah, and that's an industry-standard production deployment.

Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 17:43:03 UTC, Seb wrote: On Wednesday, 8 June 2016 at 17:05:42 UTC, Jonathan Marler wrote: On Wednesday, 8 June 2016 at 15:51:58 UTC, Adam D. Ruppe wrote: On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad wrote: The forum-index http header report: Ser

Fibers under the hood

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
I've googled and searched through the forums but haven't found too much on how fibers are implemented. How does yield return execution to the caller but then resume execution in the same place on the next call? Also some information on how the fiber call stack works would be nice. I'm assumi

Re: Fibers under the hood

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote: On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote: I've googled and searched through the forums but haven't found too much on how fibers are implemented. How does yield return execution to the caller but then resume executi

Re: Fibers under the hood

2016-06-09 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 9 June 2016 at 11:45:01 UTC, Andrew Edwards wrote: On 6/9/16 2:15 PM, Jonathan Marler wrote: On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote: On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote: I've googled and searched through the forums but haven't found too

Bug in Rdmd?

2016-06-13 Thread Jonathan Marler via Digitalmars-d-learn
This code doesn't seem to work with rdmd. Is this a bug? import std.stdio : byLine; int main(string[] args) { foreach(line; stdin.byLine) { } return 0; } Compiler Output: Error: module std.stdio import 'byLine' not found

Re: Bug in Rdmd?

2016-06-13 Thread Jonathan Marler via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 01:35:32 UTC, Jeremy DeHaan wrote: On Tuesday, 14 June 2016 at 01:05:46 UTC, Jonathan Marler wrote: This code doesn't seem to work with rdmd. Is this a bug? import std.stdio : byLine; int main(string[] args) { foreach(line; stdin.byLine) { } return

Re: Bug in Rdmd?

2016-06-13 Thread Jonathan Marler via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 03:40:01 UTC, Adam D. Ruppe wrote: On Tuesday, 14 June 2016 at 03:15:04 UTC, Jonathan Marler wrote: It actually is a free function no, it isn't, it is on File. Your code doesn't compile on my dmd (and indeed it shouldn't on yours either unless you have a version m

Forward References

2016-06-27 Thread Jonathan Marler via Digitalmars-d-learn
Do the various D compilers use multiple passes to handle forward references or some other technique?

Cast vs Virtual Method vs TypeId?

2016-06-29 Thread Jonathan Marler via Digitalmars-d-learn
I'd like to hear peoples thoughts on the various solutions for the following problem. Say you have some hierarchy of classes like: class GameObject { // ... } class Entity : GameObject { // ... } class Player : Entity { // ... } class Enemy : Entity { // ... } // ... Assume you have a

Re: Cast vs Virtual Method vs TypeId?

2016-06-30 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 30 June 2016 at 00:27:57 UTC, rikki cattermole wrote: On 30/06/2016 12:25 PM, Jonathan Marler wrote: Assume you have a function that accepts a GameObject but does something special if that GameObject happens to be an instance of the Player class. How would you go about determining

Associative array of const items

2016-06-30 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to have an associative array of const values? I thought it would have been: const(T)[K] map; map[x] = y; but the second line gives Error: cannot modify const expression. I would think that the const(T)[K] would behave similarly to const(T)[], where you can modify the array, ju

Re: Associative array of const items

2016-07-01 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 1 July 2016 at 06:57:59 UTC, QAston wrote: On Thursday, 30 June 2016 at 17:08:45 UTC, Jonathan Marler wrote: Is there a way to have an associative array of const values? I thought it would have been: const(T)[K] map; map[x] = y; but the second line gives Error: cannot modify const

Casting classes

2016-07-01 Thread Jonathan Marler via Digitalmars-d-learn
How do casts work under the hood? I'm mostly interested in what needs to be done in order to cast a class to a subclass. I'd like to know what is being done to determine whether the object is a valid instance of the cast type. If the code is implemented in the druntime, a pointer to where it

Re: Casting classes

2016-07-01 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 1 July 2016 at 17:34:25 UTC, Basile B. wrote: On Friday, 1 July 2016 at 17:32:26 UTC, Basile B. wrote: On Friday, 1 July 2016 at 15:45:35 UTC, Jonathan Marler wrote: How do casts work under the hood? I'm mostly interested in what needs to be done in order to cast a class to a subcla

Reason for mypackage/package.d instead of mypackage.d

2014-11-10 Thread Jonathan Marler via Digitalmars-d-learn
I was perusing a PR for phobos where std/range.d was split into submodules and std/range.d was moved to std/range/package.d I was wondering why a package module had to be called "package.d" instead of just being the package name. For example, instead of moving std/range.d to std/range/package

Delegate returning itself

2014-12-06 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to create a delegate that returns itself? alias MyDelegate delegate() MyDelegate; // OR alias MyDelegate = MyDelegate delegate(); When I compile this I get: Error: alias MyDelegate recursive alias declaration The error makes sense but I still feel like there should be a way to

Re: Delegate returning itself

2014-12-08 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 6 December 2014 at 15:46:16 UTC, Adam D. Ruppe wrote: The problem is the recursive *alias* rather than the delegate. Just don't use the alias name inside itself so like alias MyDelegate = void delegate() delegate(); will work. The first void delegate() is the return value of the

Re: Delegate returning itself

2014-12-08 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 8 December 2014 at 14:08:33 UTC, Jonathan Marler wrote: On Saturday, 6 December 2014 at 15:46:16 UTC, Adam D. Ruppe wrote: The problem is the recursive *alias* rather than the delegate. Just don't use the alias name inside itself so like alias MyDelegate = void delegate() delegate()

Re: Delegate returning itself

2014-12-08 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 8 December 2014 at 14:38:37 UTC, Marc Schütz wrote: On Monday, 8 December 2014 at 14:31:53 UTC, Jonathan Marler wrote: On Monday, 8 December 2014 at 14:08:33 UTC, Jonathan Marler wrote: On Saturday, 6 December 2014 at 15:46:16 UTC, Adam D. Ruppe wrote: The problem is the recursive *a

Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which version of windows you are on? Note: I'm specifically talking about runtime because I want the same binary to r

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which

Tuples not working?

2015-01-09 Thread Jonathan Marler via Digitalmars-d-learn
import std.stdio; import std.typecons; void main() { alias TL = Tuple!(int, long, float); foreach (i, T; TL) writefln("TL[%d] = %s", i, typeid(T)); } Why is this not working? D:\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(419): Error: need 'this' for '_expand_field_0' of type 'int'

I can has @nogc and throw Exceptions?

2015-02-13 Thread Jonathan Marler via Digitalmars-d-learn
This question comes from wanting to be able to throw an exception in code that is @nogc. I don't know if it's possible but I'd like to be able to throw an exception without allocating memory for the garbage collector? You can do it in C++ so I think you should be able to in D. One idea I ha

Re: I can has @nogc and throw Exceptions?

2015-02-13 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 13 February 2015 at 19:13:02 UTC, Steven Schveighoffer wrote: You need to actually allocate the memory on the heap. Your data lives on the stack frame of main, which goes away as soon as main exits, and your exception is caught outside main. -Steve Yes I am aware of this. That do

Re: I can has @nogc and throw Exceptions?

2015-02-13 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 13 February 2015 at 19:10:00 UTC, Adam D. Ruppe wrote: On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler wrote: T construct(T,A...)(void* buffer, A args) { return (cast(T)buffer).__ctor(args); } This is wrong, you need to initialize the memory first to the proper values

@nogc with assoc array

2015-02-16 Thread Jonathan Marler via Digitalmars-d-learn
Why is the 'in' operator nogc but the index operator is not? void main() @nogc { int[int] a; auto v = 0 in a; // OK auto w = a[0]; // Error: indexing an associative // array in @nogc function main may // cause GC allocation }

Re: @nogc with assoc array

2015-02-16 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 16 February 2015 at 17:58:10 UTC, Benjamin Thaut wrote: Because the index operator throws a OutOfRange exception and throwing exceptions allocates, maybe? Oh...I hadn't thought of that! Thanks for the quick response.

Re: @nogc with assoc array

2015-02-16 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 16 February 2015 at 19:12:45 UTC, FG wrote: Range violation is an Error, but never mind that. The real question is: given all the work related to @nogc, wouldn't it be better for such common Errors to be preallocated and only have file and line updated when they are thrown? @nogc a

Re: @nogc with assoc array

2015-02-16 Thread Jonathan Marler via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 00:00:54 UTC, FG wrote: Yes, they would be in TLS. I know exceptions in general are a complex problem, therefore I limited the comment only to errors, because forbidding the use of `aa[key]` in @nogc seemed odd (although I do think that `aa.get(key, default)` and

Quick help on version function parameter

2015-02-18 Thread Jonathan Marler via Digitalmars-d-learn
Does anyone know a good way to support versioned function parameters? Say, in one version I want a variable to be a global and in another I want it to be a parameter. version(GlobalVersion) { int x; void foo() { // A huge function that uses x } } else { void foo(int

Re: Quick help on version function parameter

2015-02-18 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 18 February 2015 at 23:49:26 UTC, Adam D. Ruppe wrote: I'd write a foo_impl which always takes a parameter. Then do the versioned foo() functions which just forward to it: void foo_impl(int x) { long function using x here } version(globals) { int x; void foo() { foo_i

Is this possible in D?

2015-02-19 Thread Jonathan Marler via Digitalmars-d-learn
I am having a heck of a time trying to figure out how to do this. How do I change the attributes of a function based on the version without copying the function body? For example: version(StaticVersion) { static void myLongFunction() { // long body ... } } else { void

Re: Is this possible in D?

2015-02-19 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 19 February 2015 at 17:23:47 UTC, Mike Parker wrote: I agree that string mixins can kill readability. I encountered that when I used them to support both D1 and D2 in Derelict 2 years ago. But I think that when they are kept small and local as in cases like this, they aren't bad at

full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own path. The original batch script uses the %~dp0 variable for this, bu

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:33:39 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 22:28:39 UTC, zabruk70 wrote: won't? what this means? That gives the path to the .exe but he wants the path to the .d. But why? I would think the current working directory is probably adequate and th

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:39:45 UTC, Steven Schveighoffer wrote: On 7/21/16 3:54 PM, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd.

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 01:52:57 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 22:47:42 UTC, Jonathan Marler wrote: I explain in the original post. Any ideas Adam? Thanks in advance. But why does the batch script use it? Since you are rewriting anyway, maybe you can find an easier

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:57:06 UTC, Jonathan M Davis wrote: On Thursday, July 21, 2016 18:39:45 Steven Schveighoffer via Digitalmars-d- learn wrote: [...] It would be pretty terrible actually to put the executable in the source path, and in many cases, the user wouldn't even have the

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf wrote: On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran w

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 06:45:58 UTC, Jacob Carlborg wrote: On 2016-07-22 04:24, Jonathan Marler wrote: The script depends on other files relative to where it exists on the file system. I couldn't think of a better design to find these files then knowing where the script exists, can you?

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 07:57:35 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 07:47:14 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf wrote: What's wrong with __FILE__.dirName ? It's kinda weird, sometimes I've noticed that the __FILE__ keyword is an absol

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 13:30:10 UTC, Steven Schveighoffer wrote: On 7/22/16 3:47 AM, Jonathan Marler wrote: What's wrong with __FILE__.dirName ? It's kinda weird, sometimes I've noticed that the __FILE__ keyword is an absolute path, and sometimes it isn't. If you combine it with curren

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 09:37:24 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 08:36:37 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 07:57:35 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 07:47:14 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf wro

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 19:13:31 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 14:02:03 UTC, Jonathan Marler wrote: The __FILE__ trait seems to be used most useful for error messages. Another usage is for testing parsers or string functions directly on the source. E.g in "devel" mode the

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 19:23:30 UTC, Steven Schveighoffer wrote: On 7/22/16 2:43 PM, Kagamin wrote: On Friday, 22 July 2016 at 13:50:55 UTC, Jonathan Marler wrote: shell/anypath> rdmd /somedir/clean.d Removing /somedir/build... So for command rdmd /somedir/clean.d what __FILE__ contains?

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 23 July 2016 at 15:25:02 UTC, Steven Schveighoffer wrote: On 7/23/16 10:53 AM, Rufus Smith wrote: On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc co

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with virtual methods:)

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 02:17:27 UTC, Rufus Smith wrote: On Saturday, 23 July 2016 at 22:48:07 UTC, Lodovico Giaretta wrote: [...] This just isn't right. What your saying is that because someone screwed up, we must live with the screw up and build everyone around the screw up. This mental

Re: Default implementations in inherited interfaces

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 13:37:30 UTC, Saurabh Das wrote: On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: Java 8 has a 'default' keyword that allows interfaces to provide a default implementation and sub-classes c

Re: Modules

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 02:45:57 UTC, rikki cattermole wrote: On 24/07/2016 2:28 PM, Rufus Smith wrote: NM, ignore. Seems it was something else going on. Although, if you know how how dmd resolves this stuff exactly, it would be nice to know. Does it just use the module names regardless of p

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 09:03:04 UTC, Lodovico Giaretta wrote: On Sunday, 24 July 2016 at 02:17:27 UTC, Rufus Smith wrote: [...] Now you are telling me to "program by trust", because there's nothing ensuring that I remember to free everything I allocated with malloc/free, while a GC would

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:09:53 UTC, Lodovico Giaretta wrote: Remember that comparison of complex objects may require normalization, which may change the objects themselves and allocate memory. Sure but this case will be the exception. If an application really needs this they can impleme

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:41:55 UTC, Lodovico Giaretta wrote: On Sunday, 24 July 2016 at 15:28:53 UTC, Jonathan Marler wrote: Whoa wait a second...I didn't know you could do this. I thought everything had to inherit from the object class. Can you share the syntax to define a class that do

Re: full path to source file __FILE__

2016-07-27 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own pa

Re: Command Line Utility Library

2016-08-15 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 15 August 2016 at 10:48:11 UTC, Seb wrote: Are you trying to parse arguments? There's a lot of good stuff for it already: https://dlang.org/phobos/std_getopt.html https://code.dlang.org/packages/darg https://blog.thecybershadow.net/2014/08/05/ae-utils-funopt/ For configuration file

Mutable class reference to immutable class

2016-09-10 Thread Jonathan Marler via Digitalmars-d-learn
This is been bugging me for a while. Is it possible to have a mutable reference to an immutable class? In other words, can you set a class variable to an immutable class, and then set that variable to another immutable class later? Mutable "slices" to immutable data are easy: immutable(c

Module Clarification

2016-09-21 Thread Jonathan Marler via Digitalmars-d-learn
I'm working on a code generation tool and wanted to make sure my module approach was correct. The generated code has a module hierarchy, where modules can appear at any level of the hierarchy. module foo; module foo.bar; In this case, module foo and foo.bar are independent modules. The foo

Re: Stacktrace on Null Pointer Derefence

2016-09-21 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 23:36:08 UTC, Nordlöw wrote: Doing a null deref such as int* y = null; *y = 42;// boom [...] Can you include compiler command line? I use -g -gs -debug to get stack traces on windows.

Re: Module Clarification

2016-09-22 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 22 September 2016 at 11:40:17 UTC, Steven Schveighoffer wrote: This should be fine. x/package.d is equivalent to module x. Ok, it looks like no-one thought what I was doing was off-base. I guess this brings up another question. Why doesn't the compiler support modules in a hiera

Re: Module Clarification

2016-09-22 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 22 September 2016 at 15:02:01 UTC, Lodovico Giaretta wrote: I think that having package.d provides a better layout. Look at the difference between this: ls std/experimental drw-rw-rw- allocator drw-rw-rw- logger drw-rw-rw- ndslice -rw-rw-rw- typecons.d and this: ls std/exper

Re: D code optimization

2016-09-22 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 22 September 2016 at 16:09:49 UTC, Sandu wrote: It is often being claimed that D is at least as fast as C++. Now, I am fairly new to D. But, here is an example where I want to see how can this be made possible. So far my C++ code compiles in ~850 ms. While my D code runs in about

Re: Module Clarification

2016-09-22 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 22 September 2016 at 20:09:41 UTC, Steven Schveighoffer wrote: Before package.d support, you could not do any importing of packages. You could only import modules. package.d was how the compiler allowed importing packages. I don't know that there is a fundamental difference betw

Re: Module Clarification

2016-09-27 Thread Jonathan Marler via Digitalmars-d-learn
On Tuesday, 27 September 2016 at 13:48:39 UTC, Steven Schveighoffer wrote: On 9/22/16 4:16 PM, Jonathan Marler wrote: On Thursday, 22 September 2016 at 20:09:41 UTC, Steven Schveighoffer wrote: Before package.d support, you could not do any importing of packages. You could only import modules

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: 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 from

std.socket classes

2017-04-09 Thread Jonathan Marler via Digitalmars-d-learn
Does anyone know why Socket and Address in phobos were created as classes instead of structs? My guess is that making Socket a class prevents socket handle leaks because you can clean up the handle in the destructor when the memory gets freed if no one closes it. Is this the reason it is a c

Re: std.socket classes

2017-04-09 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 9 April 2017 at 14:49:14 UTC, rikki cattermole wrote: Don't think too hard, times have changed since std.socket was written. It certainly isn't designed for high performance hence e.g. libasync. What an odd response... You don't think I should ask questions about why decisions were

Re: std.socket classes

2017-04-09 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 9 April 2017 at 15:04:29 UTC, rikki cattermole wrote: On 09/04/2017 3:56 PM, Jonathan Marler wrote: On Sunday, 9 April 2017 at 14:49:14 UTC, rikki cattermole wrote: Don't think too hard, times have changed since std.socket was written. It certainly isn't designed for high performance

Re: std.socket classes

2017-04-10 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 10 April 2017 at 04:32:20 UTC, Adam D. Ruppe wrote: On Sunday, 9 April 2017 at 14:47:39 UTC, Jonathan Marler wrote: Does anyone know why Socket and Address in phobos were created as classes instead of structs? It is probably just the historical evolution, but I find it pretty handy

Re: std.socket classes

2017-04-10 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 10 April 2017 at 18:57:13 UTC, Adam D. Ruppe wrote: On Monday, 10 April 2017 at 16:18:20 UTC, Jonathan Marler wrote: An interesting benefit. However, I don't think this is the ideal way to support such a use case. If I was doing it myself, I'd probably do an interface / final class

Re: Output-Range and char

2017-04-23 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 23 April 2017 at 11:17:37 UTC, Mafi wrote: Hi there, every time I want to use output-ranges again they seem to be broken in a different way (e.g. value/reference semantics). This time it is char types and encoding. [...] Use sformat: import std.format, std.stdio; void main() {

Re: Binding a udp socket to a port(on the local machine)

2017-04-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 22 April 2017 at 21:24:33 UTC, Chainingsolid wrote: I couldn't figure out how to make a udp socket bound to a port of my choosing on the local machine, to use for listening for incoming connections. I assume you meant "incoming datagrams" and not "incoming connections". import

range of ranges into one range?

2017-06-25 Thread Jonathan Marler via Digitalmars-d-learn
I'm using the phobos "chain" function to iterate over a set of string arrays. However, one of the variables is actually an array of structs that each contain a string array. So I use "map" to get a range of string arrays, but "chain" expects each variable to be a string array, not a range of

Re: range of ranges into one range?

2017-06-26 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 26 June 2017 at 06:19:07 UTC, rikki cattermole wrote: Perhaps? http://dlang.org/phobos/std_algorithm_iteration.html#.joiner Thank you.