Re: Question on @nothrow

2017-06-02 Thread Vasileios Anagnostopoulos via Digitalmars-d-learn
On Thursday, 1 June 2017 at 17:03:52 UTC, Ali Çehreli wrote: On 06/01/2017 08:41 AM, Vasileios Anagnostopoulos wrote: //If I do not know void haveToCommunicateWithAli() { sendEmailToAli(); } //can blow-up after code has shipped //and have no chance to recover What shall I do in this case? T

Re: Question on @nothrow

2017-06-02 Thread Vasileios Anagnostopoulos via Digitalmars-d-learn
On Friday, 2 June 2017 at 07:33:05 UTC, Vasileios Anagnostopoulos wrote: On Thursday, 1 June 2017 at 17:03:52 UTC, Ali Çehreli wrote: [...] But still I believe that @nothrow should be mandatory if there is no possibility for a function to throw something. I understand that in the DLL/LIB lev

Re: D scripting in D

2017-06-02 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-06-02 at 02:39 +, Stefan Koch via Digitalmars-d-learn wrote: > […] > The D compiler is fast enough that it will not break your flow. > This argument may work for you but it definitely doesn't work for me. Using a language like Python, Groovy, Clojure, Lisp: 1. Edit 2. Run With

Re: Creating and loading D plugins in D app

2017-06-02 Thread aberba via Digitalmars-d-learn
On Friday, 2 June 2017 at 02:05:23 UTC, Stefan Koch wrote: On Thursday, 1 June 2017 at 23:24:13 UTC, aberba wrote: Want to create and load plugins written in D into a D app at run-time, the kind that can make api calls or extended main app with other functionality. I'm currently interested in

Re: Creating and loading D plugins in D app

2017-06-02 Thread aberba via Digitalmars-d-learn
On Friday, 2 June 2017 at 02:05:23 UTC, Stefan Koch wrote: On Thursday, 1 June 2017 at 23:24:13 UTC, aberba wrote: Want to create and load plugins written in D into a D app at run-time, the kind that can make api calls or extended main app with other functionality. I'm currently interested in

Re: Creating and loading D plugins in D app

2017-06-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 2 June 2017 at 11:09:05 UTC, aberba wrote: 1. Get shared libs to work in D (the best approach for all D code) I have done very little with this myself but other people have so it is doable. 1. some kind of embeddable interpreter for a scripting language like (a mini js engine) wh

Re: D scripting in D

2017-06-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 2 June 2017 at 04:50:00 UTC, Mike B Johnson wrote: 4. Passing of the hosting D app's context. this could be pretty hard to get right? You'd ideally access the data through functions and shared value types instead of loading it directly. Then you can easily do it with shared libs or

Re: D scripting in D

2017-06-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 2 June 2017 at 09:39:51 UTC, Russel Winder wrote: With D and Go, both of which claim compilation so fast you do not notice: 1. Edit 2. run rdmd Especially if you only expose to the "script" in D the same functions you'd expose to, say, a javascript script, that compile can be und

Re: Creating and loading D plugins in D app

2017-06-02 Thread aberba via Digitalmars-d-learn
On Friday, 2 June 2017 at 12:19:48 UTC, Adam D. Ruppe wrote: On Friday, 2 June 2017 at 11:09:05 UTC, aberba wrote: 1. Get shared libs to work in D (the best approach for all D code) I have done very little with this myself but other people have so it is doable. 1. some kind of embeddable in

Re: Creating and loading D plugins in D app

2017-06-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 2 June 2017 at 13:05:41 UTC, aberba wrote: Can source of script be reloaded at runtime? It is just an ordinary string. Do I have to wrap external APIs in the "global" object passed as argument to "interpreter()" Yes, anything the script calls must be exposed through that. It doe

How to cleanup array of structs?

2017-06-02 Thread Suliman via Digitalmars-d-learn
I remember that there was topic about remobing data from struct/arrays of structs. But I do not remember what is idiomatic way to do it, and can't google it. something like: struct MyTrack { ulong id; string recordDate; int velocity; int maxAllowedSpeedFo

Re: How to cleanup array of structs?

2017-06-02 Thread Biotronic via Digitalmars-d-learn
On Friday, 2 June 2017 at 13:32:02 UTC, Suliman wrote: I remember that there was topic about remobing data from struct/arrays of structs. But I do not remember what is idiomatic way to do it, and can't google it. something like: struct MyTrack { ulong id; string recordD

Re: D scripting in D

2017-06-02 Thread jmh530 via Digitalmars-d-learn
On Friday, 2 June 2017 at 02:06:27 UTC, Mike B Johnson wrote: I wonder if it is possible to somehow turn D in to a scripting language that can be run inside D? The point? To have the same uniform syntax for quickly developing scripts that can then be easily transferred, if desired, in to a co

Re: D scripting in D

2017-06-02 Thread Lewis via Digitalmars-d-learn
On Friday, 2 June 2017 at 02:06:27 UTC, Mike B Johnson wrote: I wonder if it is possible to somehow turn D in to a scripting language that can be run inside D? On a game project I'm working on at home, I've done: - Hot reloading via a DLL - A build script that runs in the background, detects f

Guide - Migrating from std.experimental.ndslice to mir-algorithm

2017-06-02 Thread Zz via Digitalmars-d-learn
Hi, Just tried migrating from std.experimental.ndslice to mir-algorithm. Is there a guide on how migrate old code? I used the following imports before and using then with ndslice. import std.experimental.ndslice; import std.algorithm : each, max, sort; import std.range : iota, repeat; simpl

Re: D scripting in D

2017-06-02 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 2 June 2017 at 02:06:27 UTC, Mike B Johnson wrote: I wonder if it is possible to somehow turn D in to a scripting language that can be run inside D? The point? To have the same uniform syntax for quickly developing scripts that can then be easily transferred, if desired, in to a co

Re: Creating and loading D plugins in D app

2017-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 02, 2017 at 12:19:48PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Friday, 2 June 2017 at 11:09:05 UTC, aberba wrote: > > 1. Get shared libs to work in D (the best approach for all D code) > > I have done very little with this myself but other people have so it is > doabl

Re: D scripting in D

2017-06-02 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 2 June 2017 at 16:13:03 UTC, Laeeth Isharc wrote: On Friday, 2 June 2017 at 02:06:27 UTC, Mike B Johnson wrote: [...] Stefan Koch has written a good part of an interpreter for D AST, no? And I guess the lexing and parsing stage doesn't take so long, whereas not having to link save

Re: howto count lines - fast

2017-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 01, 2017 at 08:39:07AM +0100, Russel Winder via Digitalmars-d-learn wrote: > On Wed, 2017-05-31 at 16:37 -0700, H. S. Teoh via Digitalmars-d-learn > wrote: > > > […] > > With D, we can have the cake and eat it too.  The understandable / > > naïve implementation can be available as a f

Re: Mixin in Inline Assembly

2017-06-02 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 1 June 2017 at 12:00:45 UTC, Era Scarecrow wrote: So why is the offset off by 14h (20 bytes)? It's not like we need a to set a ptr first. Go figure i probably found a bug... Well as a side note a simple yet not happy workaround is making a new array slice of the memory and th

Re: D scripting in D

2017-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 02, 2017 at 05:22:20PM +, Stefan Koch via Digitalmars-d-learn wrote: > On Friday, 2 June 2017 at 16:13:03 UTC, Laeeth Isharc wrote: > > On Friday, 2 June 2017 at 02:06:27 UTC, Mike B Johnson wrote: > > > [...] > > > > Stefan Koch has written a good part of an interpreter for D AST

Re: D scripting in D

2017-06-02 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 2 June 2017 at 17:22:20 UTC, Stefan Koch wrote: On Friday, 2 June 2017 at 16:13:03 UTC, Laeeth Isharc wrote: On Friday, 2 June 2017 at 02:06:27 UTC, Mike B Johnson wrote: [...] Stefan Koch has written a good part of an interpreter for D AST, no? And I guess the lexing and parsing

Re: D scripting in D

2017-06-02 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 2 June 2017 at 17:50:30 UTC, H. S. Teoh wrote: On Fri, Jun 02, 2017 at 05:22:20PM +, Stefan Koch via Digitalmars-d-learn wrote: On Friday, 2 June 2017 at 16:13:03 UTC, Laeeth Isharc wrote: > [...] No there is not. First it's woefully incomplete and secondly it's tightly bound t

Re: D scripting in D

2017-06-02 Thread Mike B Johnson via Digitalmars-d-learn
On Friday, 2 June 2017 at 15:55:53 UTC, Lewis wrote: On Friday, 2 June 2017 at 02:06:27 UTC, Mike B Johnson wrote: I wonder if it is possible to somehow turn D in to a scripting language that can be run inside D? On a game project I'm working on at home, I've done: - Hot reloading via a DLL -

Re: Creating and loading D plugins in D app

2017-06-02 Thread aberba via Digitalmars-d-learn
On Thursday, 1 June 2017 at 23:24:13 UTC, aberba wrote: Want to create and load plugins written in D into a D app at run-time, the kind that can make api calls or extended main app with other functionality. I'm currently interested in it for a vibe.d app. How does these stuff work? Plugin s

Re: Creating and loading D plugins in D app

2017-06-02 Thread Mike B Johnson via Digitalmars-d-learn
On Friday, 2 June 2017 at 12:19:48 UTC, Adam D. Ruppe wrote: On Friday, 2 June 2017 at 11:09:05 UTC, aberba wrote: 1. Get shared libs to work in D (the best approach for all D code) I have done very little with this myself but other people have so it is doable. 1. some kind of embeddable in

Trouble with SList for generic Stack class

2017-06-02 Thread Mark via Digitalmars-d-learn
Hello, I am trying to make a class that can accept any type as an argument. Here is the class: import std.container: SList; class Stack { private SList!T list; private int _size; this(T)() { list = SList!T; _size = 0; } public void push(T)(T item) { list.insertFron

Re: Trouble with SList for generic Stack class

2017-06-02 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 2 June 2017 at 22:21:07 UTC, Mark wrote: Hello, I am trying to make a class that can accept any type as an argument. [...] the stack class needs to be a template as well. This is not java ;)

Re: Trouble with SList for generic Stack class

2017-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 02, 2017 at 10:21:07PM +, Mark via Digitalmars-d-learn wrote: > Hello, > > I am trying to make a class that can accept any type as an argument. > > Here is the class: > > > import std.container: SList; > > > class Stack { > > private SList!T list; > private int _size; >

Re: Trouble with SList for generic Stack class

2017-06-02 Thread Mark via Digitalmars-d-learn
Awesome. That worked. On Friday, 2 June 2017 at 22:30:28 UTC, Stefan Koch wrote: On Friday, 2 June 2017 at 22:21:07 UTC, Mark wrote: Hello, I am trying to make a class that can accept any type as an argument. [...] the stack class needs to be a template as well. This is not java ;) St

Re: Trouble with SList for generic Stack class

2017-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 02, 2017 at 11:05:43PM +, Mark via Digitalmars-d-learn wrote: [...] > Stefan, what do you mean that it must be a template? > > Am I supposed to write template Struct(T) { class Stack { ... } }? No, he means to turn class Stack into a template by adding a template parameter to it,

Re: Trouble with SList for generic Stack class

2017-06-02 Thread Ali Çehreli via Digitalmars-d-learn
You've probably seen H. S. Teoh's answer but still... :) On 06/02/2017 04:05 PM, Mark wrote: > Am I supposed to write template Struct(T) { class Stack { ... } }? Not necessary because in this case it's the same thing as class Stack(T) { // Don't templatize functions in here (in general) }

Re: Trouble with SList for generic Stack class

2017-06-02 Thread Mark via Digitalmars-d-learn
On Friday, 2 June 2017 at 23:34:14 UTC, Ali Çehreli wrote: You've probably seen H. S. Teoh's answer but still... :) ... Ali Awesome, thanks everyone!

Re: D scripting in D

2017-06-02 Thread Lewis via Digitalmars-d-learn
On Friday, 2 June 2017 at 20:47:31 UTC, Mike B Johnson wrote: Would you mind, when you get some time, to write up a more detailed analysis of the problems you had to overcome to get it to work? Possibly we could get some type of library solution that just "works" with very little change and res

Re: D scripting in D

2017-06-02 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-06-02 at 12:27 +, Adam D. Ruppe via Digitalmars-d- learn wrote: > On Friday, 2 June 2017 at 09:39:51 UTC, Russel Winder wrote: > > With D and Go, both of which claim compilation so fast you do  > > not notice: > > 1. Edit > 2. run rdmd > There is no rdmd on Fedora Rawhide. There

Re: D scripting in D

2017-06-02 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-06-02 at 20:47 +, Mike B Johnson via Digitalmars-d- learn wrote: > […] > > Would you mind, when you get some time, to write up a more  > detailed analysis of the problems you had to overcome to get it  > to work? Possibly we could get some type of library solution that  > just "wo

Re: Guide - Migrating from std.experimental.ndslice to mir-algorithm

2017-06-02 Thread 9il via Digitalmars-d-learn
On Friday, 2 June 2017 at 16:08:20 UTC, Zz wrote: Hi, Just tried migrating from std.experimental.ndslice to mir-algorithm. Is there a guide on how migrate old code? I used the following imports before and using then with ndslice. import std.experimental.ndslice; import std.algorithm : each,

difference between x = Nullable.init and x.nullify

2017-06-02 Thread vit via Digitalmars-d-learn
Hello, What's the difference between x = Nullable!Test.init and x.nullify? class Test{} void test()pure nothrow{ Nullable!Test x; x = Nullable!Test.init; //OK x.nullify; //Error: function 'std.typecons.Nullable!(Test).Nullable.nullify!().nullify' is not nothrow }

Re: howto count lines - fast

2017-06-02 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-06-02 at 10:32 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > > Also, compiler implementors do still have to do the "heroics", or > rather, teach the compiler to do the "heroics" when compiling > straightforward code. So while the general programmer probably will > have > le

Re: difference between x = Nullable.init and x.nullify

2017-06-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 03, 2017 05:52:55 vit via Digitalmars-d-learn wrote: > Hello, > What's the difference between x = Nullable!Test.init and > x.nullify? > > > class Test{} > > void test()pure nothrow{ > Nullable!Test x; > > x = Nullable!Test.init; //OK > x.nullify; //Erro

Re: howto count lines - fast

2017-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jun 03, 2017 at 07:00:47AM +0100, Russel Winder via Digitalmars-d-learn wrote: [...] > There are many different sorts of programming. Operating systems, > compilers, GUIs, Web services, machine learning, etc., etc. all > require different techniques. Also there are always new areas, where

Re: difference between x = Nullable.init and x.nullify

2017-06-02 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 3 June 2017 at 06:19:29 UTC, Jonathan M Davis wrote: looking at what rt_finalize does, I don't see why it couldn't be nothrow. So, unless I'm missing something, it seems like that would be a good enhancement. - Jonathan M Davis Presently, rt_finalize cannot be made nothrow, or