Re: Beerconf April 2021

2021-04-23 Thread Simen Kjærås via Digitalmars-d-announce

On Friday, 23 April 2021 at 16:53:03 UTC, Iain Buclaw wrote:
*This* **reminds** ~~me~~ __that__ I'm yet to give markdown a 
try from my own mail client.


It seems you're missing a header. From Steve's post:

Content-Type: text/plain; charset=utf-8; format=flowed; 
delsp=no; markup=markdown


--
  Simen


Re: From the D Blog: A Pattern for Head-mutable Structures

2020-07-03 Thread Simen Kjærås via Digitalmars-d-announce

On Friday, 3 July 2020 at 07:58:31 UTC, Nick Treleaven wrote:

On Thursday, 25 June 2020 at 13:17:55 UTC, jmh530 wrote:
Good piece. I've been following the recent thread, but this 
really helped make some things clear.


Do you have a link to that thread (or title) please?


Pretty sure it's the stuff in std.v2020.algorithm 
(https://forum.dlang.org/post/rcqk4f$1dou$1...@digitalmars.com). 
That discussion was part of the reason I got the post published 
right now. (the other reasons being I'd had it lying about for a 
long while, and a DConf 2020 presentation just wasn't going to 
happen)


--
  Simen


Re: addle 0.1.0 - argument-dependent lookup for UFCS functions

2020-06-22 Thread Simen Kjærås via Digitalmars-d-announce

On Sunday, 21 June 2020 at 00:06:12 UTC, Paul Backus wrote:

import addle;
import std.range;

// Import a type from another module
import mylib: MyStruct;

// Define range primitives for MyStruct
bool empty(MyStruct a) { return false; }
string front(MyStruct a) { return "ok"; }
void popFront(MyStruct a) {}

// MyStruct isn't considered an input range, because
// std.range can't see our UFCS methods.
static assert(isInputRange!MyStruct == false);

// ...but extending it makes those methods visible.
static assert(isInputRange!(Extended!MyStruct));

void main()
{
import std.range: take, only;
import std.algorithm: equal;

MyStruct myStruct;

// Now we can use all of the standard range algorithms
assert(
myStruct.extended
.take(3)
.equal(only("ok", "ok", "ok"))
);
}


As a demonstration of what you can do in D, I love this. Maybe 
one day I'll even find a use for it. Good work!


--
  Simen


Re: Release D 2.090.0

2020-01-08 Thread Simen Kjærås via Digitalmars-d-announce

On Tuesday, 7 January 2020 at 10:30:09 UTC, Martin Nowak wrote:

Glad to announce D 2.090.0, ♥ to the 48 contributors.

This release comes with the ability to convert lazy parameters 
to delegates, new intrinsics to force rounding to specific 
floating point precision, unittest builds that no longer 
execute main by default, a new GC.inFinalizer API, and various 
other changes.


http://dlang.org/download.html 
http://dlang.org/changelog/2.090.0.html


-Martin


Something seems to be wrong with the 2.090.0 Windows installer. 
After successfully installing, it proceeds to delete every file 
it has just added.


Looking closely at how it happens, it seems that it might 
actually be caused by the uninstaller deleting itself and the 
directory it's in. If I wait long after the previous version has 
been uninstalled before clicking 'next', it doesn't happen.


So, how to reproduce:

1) have a previous DMD version installed
2) start the 2.090.0 installer
3) answer yes to uninstalling the previous version
4) quickly finish installing 2.090.0

If you do this with the install folder open in an explorer 
window, you should see the files disappearing during the 
uninstall of the previous version, until the only item in the D 
folder is uninstall.exe. As the new install proceeds more files 
and folders will be added, and finally they will all be deleted 
again, sometimes leaving an empty folders, other times a partial 
installation (I've only once managed to get a partial 
installation).


--
  Simen


Re: Flexible Default Function Parameters via structs with Nullable Fields

2019-04-30 Thread Simen Kjærås via Digitalmars-d-announce

On Tuesday, 30 April 2019 at 13:10:54 UTC, Adam D. Ruppe wrote:

On Tuesday, 30 April 2019 at 08:20:29 UTC, JN wrote:
It might be nifty by D standards, but for a person not 
familiar with D


Or, as someone familiar with D, I wonder why not just use a 
plain struct. D allows you to set initial values for struct 
members plainly.


Yeah, though I can see some use cases for a struct with all 
nullable fields and a way to combine with a regular version of 
that struct. This could be made a lot easier than in the article:


import std.traits : FieldNameTuple;
import std.typecons : Nullable;

struct Partial(T) if (is(T == struct)) {
static foreach (e; FieldNameTuple!T)
mixin("Nullable!(typeof(__traits(getMember, T, e))) 
"~e~";");

}

auto combine(T, PT)(T t, PT pt) if (is(PT == Partial!T)) {
T result;
static foreach (e; FieldNameTuple!T)
__traits(getMember, result, e) = __traits(getMember, pt, 
e).get(__traits(getMember, t, e));

return result;
}

struct S {
int x,y;
}

unittest {
S a = S(1,2);
Partial!S b;
b.x = 3;
assert(a.combine(b) == S(3,2));
}

Now, for the abomination that is 
callMemberFunctionWithParamsStruct!(t, "f")(combined)... It's 
just t.f(combined.tupleof) in a bad disguise, and I really can't 
see the benefit.


Lastly, the use of a mixin to define the struct ensures you can't 
put methods on the struct, thus drastically reducing usability.


All in all, it's a fun beginner's project, but the quality may 
not be good enough that it should be on the blog.


--
  Simen


Re: DMD metaprogramming enhancement

2019-04-26 Thread Simen Kjærås via Digitalmars-d-announce

On Friday, 26 April 2019 at 06:29:04 UTC, Simen Kjærås wrote:

On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:

Hello everyone,

I am happy to announce that in the next DMD release you will 
be able to more freely enjoy your metaprograming experience 
now that a long-standing limitation has been lifted.


You can now instantiate local and member templates with local 
symbols.


Example:
---
struct S
{
private int _m;
void exec(alias fun)()
{
fun(_m);
}
}

unittest
{
int localVar;

void set(int i)
{
localVar = i;
}

auto obj = S(10);
obj.exec!set();   // no error or warning

assert(localVar == 10);
}
---

I hope you enjoy!


You have no idea how happy I am to hear this has been fixed! So 
many of my designs have been hamstrung by 5710, and it's been 
around since the dawn of time.


BTW, at least two people have promised money outside BountySource 
to have 5710 fixed:

https://forum.dlang.org/post/gjzrklkxfmgjjdfor...@forum.dlang.org

--
  Simen


Re: DMD metaprogramming enhancement

2019-04-26 Thread Simen Kjærås via Digitalmars-d-announce

On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:

Hello everyone,

I am happy to announce that in the next DMD release you will be 
able to more freely enjoy your metaprograming experience now 
that a long-standing limitation has been lifted.


You can now instantiate local and member templates with local 
symbols.


Example:
---
struct S
{
private int _m;
void exec(alias fun)()
{
fun(_m);
}
}

unittest
{
int localVar;

void set(int i)
{
localVar = i;
}

auto obj = S(10);
obj.exec!set();   // no error or warning

assert(localVar == 10);
}
---

I hope you enjoy!


You have no idea how happy I am to hear this has been fixed! So 
many of my designs have been hamstrung by 5710, and it's been 
around since the dawn of time.


--
  Simen


Re: sumtype 0.8.3

2019-02-26 Thread Simen Kjærås via Digitalmars-d-announce

On Tuesday, 26 February 2019 at 12:52:11 UTC, JN wrote:

On Monday, 25 February 2019 at 20:31:43 UTC, Paul Backus wrote:
SumType is a generic sum type for modern D. It is meant as an 
alternative to

`std.variant.Algebraic`.


Is it a better alternative? Seems like it from the description. 
If it's objectively better on all fronts, perhaps it should be 
considered for inclusion into Phobos, as a replacement for the 
existing Algebraic?


It's not a perfect superset of Algebraic and Variant in Phobos, 
so it's not a strictly better alternative. The feature that is 
missing is SumType can't hold arbitrary types, only the types 
specified in its template parameters. However, for the case where 
the set of possible types is limited, it's strictly better.


--
  Simen


Re: intel-intrinsics v1.0.0

2019-02-14 Thread Simen Kjærås via Digitalmars-d-announce

On Wednesday, 13 February 2019 at 23:26:48 UTC, Crayo List wrote:
On Wednesday, 13 February 2019 at 19:55:05 UTC, Guillaume 
Piolat wrote:
On Wednesday, 13 February 2019 at 04:57:29 UTC, Crayo List 
wrote:
However (for those who are unaware) there is an alternative 
way that is (arguably) better;

https://ispc.github.io/index.html

You can write portable vectorized code that can be trivially 
invoked from D.


ispc is another compiler in your build, and you'd write in 
another language, so it's not really the same thing.


That's mostly what I said, except that I did not say it's the 
same thing.
It's an alternative way to produce vectorized code in a 
deterministic and portable way.


While you didn't say it was the same thing, you did say it's an 
alternative that 'is arguably better'. Adding another compiler 
using another language is arguably worse, so there are tradeoffs 
here, which Guillaume may have felt were undercommunicated (I 
know I did).


That said, it *is* a good alternative in some cases, and may well 
be worth pointing out in a thread like this.


--
  Simen


Re: intel-intrinsics v1.0.0

2019-02-05 Thread Simen Kjærås via Digitalmars-d-announce
On Wednesday, 6 February 2019 at 01:05:29 UTC, Guillaume Piolat 
wrote:
"intel-intrinsics" is a DUB package for people interested in 
x86 performance that want neither to write assembly, nor a 
LDC-specific snippet... and still have fastest possible code.


Neat. Question: On Github it's stated that implicit conversions 
aren't supported, with this example:


__m128i b = _mm_set1_epi32(42);
__m128 a = b; // NO, only works in LDC

Couldn't this be solved through something like this:

struct __m128 {
float4 value;
alias value this;
void opAssign(__m128i rhs) {
value = cast(float4)rhs.value;
}
}

--
  Simen


5 reasons the D programming language is a great choice for development

2019-01-30 Thread Simen Kjærås via Digitalmars-d-announce

I found this article espousing D's strengths today:
https://opensource.com/article/17/5/d-open-source-software-development


Re: Blog post: What D got wrong

2018-12-11 Thread Simen Kjærås via Digitalmars-d-announce
On Tuesday, 11 December 2018 at 14:38:25 UTC, Steven 
Schveighoffer wrote:

On 12/11/18 5:45 AM, Atila Neves wrote:

A few things that have annoyed me about writing D lately:

https://atilanevesoncode.wordpress.com/2018/12/11/what-d-got-wrong/


Agree with most of this. UFCS for templates would be awesome, 
but the syntax is trickier, since instantiation uses ! instead 
of .


I can't see how you get around the ambiguities, especially when 
a template could be a UFCS function.


I believe a reasonable case can be made for .! for UFCS - it's 
currently invalid syntax and will not compile, and ! is the 
symbol we already associate with template instantiation:


alias memberFunctions = __traits(allMembers, T)
.!staticMap!Member
.!Filter!(isSomeFunction);

--
  Simen


Re: Update regarding the Nullable issue

2018-07-12 Thread Simen Kjærås via Digitalmars-d-announce

On Wednesday, 11 July 2018 at 10:43:40 UTC, FeepingCreature wrote:

Destructors are not called for fields embedded in unions.

On the one hand this is a horrible, horrible hack. On the 
other, whee!


Not only a horrible hack, but a bug, and something you really 
can't rely on working in the future. Especially since this 
behavior is only observed with named unions, not with anonymous 
ones.


I'll also mention section 14.19 2 on the Structs, Unions page 
(https://dlang.org/spec/struct.html):


2. Unions may not have fields that have destructors.

Whether that means it's undefined behavior or the compiler should 
statically disallow it is up for debate, I guess.


--
  Simen


Re: Complicated Types: Prefer “alias this” Over “alias” For Easier-To-Read Error Messages

2018-05-21 Thread Simen Kjærås via Digitalmars-d-announce

On Monday, 21 May 2018 at 14:48:23 UTC, Mike Parker wrote:
Nick Sabaluasky's first post to the D Blog is a tip on how to 
create an aliased type that keeps its name in error messages.


Nice. Interestingly, the error message references the wrong type 
when trying to access static members:


struct MT {
int _payload;
alias _payload this;
}

unittest {
MT a;
a.foo = 3;  // Error: no property foo for type MT
MT.foo = 3; // Error: no property foo for type int
}

https://issues.dlang.org/show_bug.cgi?id=18892

--
  Simen


Re: Seeking lecturer - D language (Moscow)

2018-03-14 Thread Simen Kjærås via Digitalmars-d-announce
On Wednesday, 14 March 2018 at 11:38:20 UTC, Dmitry Olshansky 
wrote:


- I owe you a bottle of your favorite beverage and your 
favorite bug in Bugzilla if you agree ;)


https://issues.dlang.org/show_bug.cgi?id=5710 might be worth it, 
even if it means moving from friends and a comfy job in Norway...


--
  Simen


Re: Article: Why Const Sucks

2018-03-07 Thread Simen Kjærås via Digitalmars-d-announce

On Tuesday, 6 March 2018 at 17:41:42 UTC, H. S. Teoh wrote:
Yeah, Andrei has admitted before that this is probably what he 
would do today, if he were given a second chance to design 
ranges.  But at the time, the landscape of D was rather 
different, and certain language features didn't exist yet 
(sorry, can't recall exactly which off the top of my head), so 
he settled with the compromise that we have today.


As they say, hindsight is always 20/20.  But it wasn't so easy 
to foresee the consequences at the time when the very concept 
of ranges was still brand new.


Andrei's 'On Iteration'[0] was published 2009-11-09. Postblits 
had been in the language for about a year and a half[1], and 
@disable arrived early 2010[2]. Both features were probably too 
new to warrant being an integral part of the design of ranges.


--
  Simen

[0]: http://www.informit.com/articles/printerfriendly/1407357
[1]: https://dlang.org/changelog/2.012.html
[2]: https://dlang.org/changelog/2.040.html


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Simen Kjærås via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Nice! Good overview of many of the good things in D.

Nitpicks:

I used the following rdmd script to generate a simple CSV file 
with 10 fields and 10m lines:


rdmd --eval='10.iota.map!(a=> "field".text(a)).join(",")
.repeat(10_00_000).joiner("\n").writeln' > input_big.csv


10_00_000 should probably be 10_000_000.


They are only view on the actual memory and you don’t copy the 
array, but just the view on (in D it’s called a slice).


Missing some words here: "only *a* view". "but just the view on" 
seems to be missing the second half of the sentence.



There's also a few typos: 'vauge' should be 'vague', 'it 
providers' should be 'it provides', 'shot yourself in the feet' 
should probably be 'shoot yourself in the foot'


Thanks for writing all this - it's a great intro to the language.

--
  Sien


Re: Scott Meyers' DConf 2014 keynote The Last Thing D Needs

2014-05-29 Thread Simen Kjærås via Digitalmars-d-announce

On 2014-05-29 03:29, Jonathan M Davis via Digitalmars-d-announce wrote:


1. The order of the dimensions of multi-dimensional static arrays is backwards
in comparison to what most everyone expects.

 int[4][5][6] foo;

is the same as

 int foo[6][5][4];

and has the same dimensions as

 auto bar = new int[][][](6, 5, 4);



IMO, it's the dynamic array creation syntax that's weird here. The 
static array syntax is sensible, easy to explain, and consistent with 
reading the type left to right. I've never used the syntax for creating 
a multidimensional dynamic array, so I was frankly surprised to see it 
worked that way.


--
  Simen



Re: Scott Meyers' DConf 2014 keynote The Last Thing D Needs

2014-05-28 Thread Simen Kjærås via Digitalmars-d-announce

On 2014-05-28 13:05, Craig Dillabaugh via Digitalmars-d-announce wrote:

On Tuesday, 27 May 2014 at 21:40:00 UTC, Walter Bright wrote:

On 5/27/2014 2:22 PM, w0rp wrote:

I'm actually a native speaker of 25 years and I didn't get it at
first. Natural
language communicates ideas approximately.


What bugs me is when people say:

   I could care less.

when they mean:

   I couldn't care less.


and:

   If you think that, you have another thing coming.

when they mean:

   If you think that, you have another think coming.


Whats wrong with If you think that, you have another thing coming.?

I've always understood it sort of like say your Father saying:

If you think that [i.e. you can steal your little brother's ice cream
cone], then  you have another thing [i.e no ice cream, but maybe the
leather strap] coming.



It's an old saying, and in more modern English might be phrased If you 
think that, you have another thought coming, i.e. you'll soon enough 
see why you're wrong.


--
  Simen