On Friday, 6 March 2020 at 04:56:28 UTC, Marcone wrote:
Is it possible change compile time errors to runtime errors in
Dlang?
If yes, how can I make it?
No it's not possible, D is a statically typed language.
Why would you want errors that can be caught at compile time to
happen at runtimes ?
Is it possible change compile time errors to runtime errors in
Dlang?
If yes, how can I make it?
On Thursday, 5 March 2020 at 20:13:11 UTC, Adnan wrote:
auto d = some!(some!int(9));
My guess would be this line is causing your trouble. That is
trying to pass an instance as a value at compile time, thus
triggering ctfe.
Since you use the `Array` object inside and that uses malloc
The following program produces an error message and it is not
clear exactly what line causes this error:
module maybe;
@nogc:
private import std.container : Array;
struct MayBe(T) {
Array!T data;
this(T datum) {
data.reserve(1);
data.insert(datu
On Thursday, 5 March 2020 at 18:33:41 UTC, Adam D. Ruppe wrote:
On Thursday, 5 March 2020 at 14:24:33 UTC, wjoe wrote:
Implement this for free functions i would do something like
this
void dispatch(alias fn, ARGS...)(Handle handle, ARGS args)
Why do you need an `alias fn` like that?
My sugg
On Thursday, 5 March 2020 at 14:46:24 UTC, Steven Schveighoffer
wrote:
On 3/5/20 9:24 AM, wjoe wrote:
but how can I call fn in the context of an object instance?
You could do it with delegates. But it's ugly:
import std.stdio;
class C
{
void foo() { writeln("Yup");}
}
void main()
{
On Thursday, 5 March 2020 at 14:24:33 UTC, wjoe wrote:
Implement this for free functions i would do something like this
void dispatch(alias fn, ARGS...)(Handle handle, ARGS args)
Why do you need an `alias fn` like that?
My suggestion would be to just use the `opDispatch` magic method
that gi
On Thursday, 5 March 2020 at 18:10:11 UTC, Martin Brezel wrote:
Unfortunately the documentation page for core.thread is
currently not available.
the official docs are lame, use my fork doc website instead:
http://dpldocs.info/experimental-docs/core.thread.html
On Thursday, 5 March 2020 at 03:04:10 UTC, Adam D. Ruppe wrote:
You can also not use `spawn` and instead give `new Thread` a
try from core.thread.
Thanks for the hint, I didn't notice core.thread at all. I will
definitely try it out.
Unfortunately the documentation page for core.thread is curr
On Thursday, 5 March 2020 at 07:44:21 UTC, Jesse Phillips wrote:
I am making an attempt convert Lua to D. This is less about the
conversion and more about exploring the tooling to make it
happen.
I have chosen to do this file by file and attempting to start
with linint. I wanted to make use o
On 3/5/20 9:24 AM, wjoe wrote:
but how can I call fn in the context of an object instance?
You could do it with delegates. But it's ugly:
import std.stdio;
class C
{
void foo() { writeln("Yup");}
}
void main()
{
alias f = C.foo;
auto c = new C;
void delegate() dg;
dg.func
Consider a Factory that creates instances of various different
resource object instances, all of which have a common interface,
and returns a handle to them.
class Factory
{
struct Handle{}
Handle create(R: Resource, ARGS...)(ARGS args)
{
auto r = new R(args);
//...
On Thursday, 5 March 2020 at 13:31:14 UTC, Adam D. Ruppe wrote:
On Thursday, 5 March 2020 at 11:03:30 UTC, mark wrote:
I want to use the Porter stemming algorithm.
There's a D implementation here:
https://tartarus.org/martin/PorterStemmer/d.txt
I think I (or ketmar and I stole it from him) po
On Thursday, 5 March 2020 at 11:03:30 UTC, mark wrote:
I want to use the Porter stemming algorithm.
There's a D implementation here:
https://tartarus.org/martin/PorterStemmer/d.txt
I think I (or ketmar and I stole it from him) ported that very
same file before:
https://github.com/adamdruppe
I suspect the problem is using .length rather than some other
size property.
I changed int to size_t and used const(char[]) etc. as suggested.
It ran but crashed. Each crash was a range violation, so for each
one I put in a guard so instead of
if ( ... m_b[m_k])
I used
if (m_k < m_b.length && ... m_b[m_k)
I did this kind of fix in three places.
The result is that it
On Thursday, 5 March 2020 at 11:31:43 UTC, mark wrote:
I've now got Martin Porter's own Java version, so I'll have a
go at porting that to D myself.
I don't think that's necessary, the errors seem easy to fix.
src/porterstemmer.d(197,13): Error: cannot implicitly convert
expression s.length o
On Thursday, 5 March 2020 at 11:12:24 UTC, drug wrote:
On 3/5/20 2:03 PM, mark wrote:
[snip]
Your code and errors seem to be not related.
OK, it is probably that the D stemmer is 19 years old!
I've now got Martin Porter's own Java version, so I'll have a go
at porting that to D myself.
On 3/5/20 2:03 PM, mark wrote:
I want to use the Porter stemming algorithm.
There's a D implementation here:
https://tartarus.org/martin/PorterStemmer/d.txt
The main public function's signature is:
char[] stem(char[] p, int i, int j)
But I work entirely in terms of strings (containing indivi
I want to use the Porter stemming algorithm.
There's a D implementation here:
https://tartarus.org/martin/PorterStemmer/d.txt
The main public function's signature is:
char[] stem(char[] p, int i, int j)
But I work entirely in terms of strings (containing individual
words), so I want to add a
On Thursday, 5 March 2020 at 08:35:52 UTC, drug wrote:
On 3/5/20 10:47 AM, mark wrote:
In Adam Ruppe's D Cookbook there're these lines in a ref
counting example:
RefCountedObject o = void; // What does this mean/do?
o.data = new Implementation();
o.data.refcount = 1;
I don't understand the fi
On Thursday, 5 March 2020 at 08:35:52 UTC, drug wrote:
On 3/5/20 10:47 AM, mark wrote:
In Adam Ruppe's D Cookbook there're these lines in a ref
counting example:
RefCountedObject o = void; // What does this mean/do?
o.data = new Implementation();
o.data.refcount = 1;
I don't understand the fi
On 3/5/20 10:47 AM, mark wrote:
In Adam Ruppe's D Cookbook there're these lines in a ref counting example:
RefCountedObject o = void; // What does this mean/do?
o.data = new Implementation();
o.data.refcount = 1;
I don't understand the first line; could someone explain please?
In D all vars
23 matches
Mail list logo