On Tuesday, 17 April 2012 at 15:18:49 UTC, bearophile wrote:
Jakob Ovrum:
return array(strippedTail);
}
The type of the return expression is dstring, not string.
What is the most elegant way or correct way to solve this
friction?
(Note: the function is used in CTFE)
On Tuesday, 17 April 2012 at 15:36:39 UTC, Ali Çehreli wrote:
The reason is, a sequence of UTF-8 code units are not a valid
UTF-8 when reversed (or retro'ed :p). But a dchar array can be
reversed.
Ali
It is absolutely possible to walk a UTF-8 string backwards.
The problem here is that arr
On Wednesday, 18 April 2012 at 05:05:20 UTC, Joseph Rushton
Wakeling wrote:
On 18/04/12 06:43, jerro wrote:
According to the comment the call to prime() is necessary
so that the result doesn't always start with the same element.
But prime() uses the gen member which is only assigned after
the
c
On 18/04/12 06:43, jerro wrote:
According to the comment the call to prime() is necessary
so that the result doesn't always start with the same element.
But prime() uses the gen member which is only assigned after the
constructor completes. So at the time when prime() is called the
gen member is
On Wednesday, 18 April 2012 at 03:47:31 UTC, Joseph Rushton
Wakeling wrote:
Can anyone explain to me why, when I compile & run this code,
the two samples seeded with the unpredictableSeed always come
out with the same starting value?
On 04/17/2012 02:00 PM, simendsjo wrote:
> Sounds like a bug. C style initializers work in other cases:
I try not to use them. I think they have this 'feature' of leaving
unspecified members uninitialized:
struct S
{
int i;
double d;
}
void main()
{
S s = { 42 }; //
On Wednesday, 18 April 2012 at 03:47:31 UTC, Joseph Rushton
Wakeling wrote:
Can anyone explain to me why, when I compile & run this code,
the two samples seeded with the unpredictableSeed always come
out with the same starting value?
Can anyone explain to me why, when I compile & run this code, the two samples
seeded with the unpredictableSeed always come out with the same starting value?
//
import std.random, std.range, std.stdio;
void main()
{
auto s = ra
On Tuesday, 17 April 2012 at 21:00:55 UTC, simendsjo wrote:
On Tue, 17 Apr 2012 22:28:31 +0200, maarten van damme
wrote:
Just for fun I decided to complete some codejam challenges in
D. At some
point I wanted to add structs to an array but I got a compiler
error. What
am I doing wrong?
cod
On 13/04/12 10:04, Dmitry Olshansky wrote:
OK, I'll see what I can do. I'd like to discuss and refine the design a
bit further before making any pull request -- should I take things over
to the Phobos mailing list for this ... ?
I'm no authority but there is this d.D newsgroup which is perfectl
Namespace:
Another idea: instead scope, "in" can get a new functionality.
Instead as a synonym for "const" it could mean "not null" for
objects.
Note that currently in D2 "in" means "scope const".
Bye,
bearophile
Another idea: instead scope, "in" can get a new functionality.
Instead as a synonym for "const" it could mean "not null" for
objects.
simendsjo:
Sounds like a bug. C style initializers work in other cases:
D language is so much irregular, so many special cases that don't
work :-)
Bye,
bearophile
On Tue, 17 Apr 2012 22:28:31 +0200, maarten van damme
wrote:
Just for fun I decided to complete some codejam challenges in D. At some
point I wanted to add structs to an array but I got a compiler error.
What
am I doing wrong?
code:
struct test{
int x;
int y;
}
void main(){
test[] why;
wh
On Tue, Apr 17, 2012 at 10:28:31PM +0200, maarten van damme wrote:
> Just for fun I decided to complete some codejam challenges in D. At
> some point I wanted to add structs to an array but I got a compiler
> error. What am I doing wrong?
>
> code:
> struct test{
> int x;
> int y;
> }
> void main(
On Tuesday, 17 April 2012 at 12:46:28 UTC, Kenji Hara wrote:
On Tuesday, 17 April 2012 at 12:04:44 UTC, Erèbe wrote:
[snip]
There is something I still don't understand :
mixin template Foo( T... )
{
//Code here
}
mixin Foo!( "Hello", "Word" ); < Good
T is TemplateTypeParameter, and matc
Ali Çehreli:
Agreed.
But I am not that sure about this particular function anymore
because for the function to be not 'strongly exception safe',
the input string must be invalid UTF-8 to begin with.
I am not sure how bad it is to not preserve the actual
invalidness of the string in that ca
Just for fun I decided to complete some codejam challenges in D. At some
point I wanted to add structs to an array but I got a compiler error. What
am I doing wrong?
code:
struct test{
int x;
int y;
}
void main(){
test[] why;
why~={3,5};
}
error:
wait.d(7): found '}' when expecting ';' following
On Tuesday, 17 April 2012 at 19:56:11 UTC, Timon Gehr wrote:
On 04/17/2012 09:16 PM, Namespace wrote:
But C++ does not do that either.
Are you asking for a full-blown non-null type system?
Yes, but of course only with a special Keyword/Storage class.
If it is not the default, how would you e
On 04/17/2012 12:57 PM, bearophile wrote:
>> The algorithm
>> above is not exception-safe because stride() may throw. But this way off
>> topic on this thread. :)
>
> You can't expect Phobos to be perfect, it needs to be improved
> iteratively. If you think that's not exception safe and and ther
Ali:
> The algorithm is smart.
The basic idea for that algorithm was mine, and Andrei was very gentle to
implement it, defining it a "Very fun exercise" :-)
http://d.puremagic.com/issues/show_bug.cgi?id=7086
> The algorithm
> above is not exception-safe because stride() may throw. But this way
On 04/17/2012 09:16 PM, Namespace wrote:
But C++ does not do that either.
Are you asking for a full-blown non-null type system?
Yes, but of course only with a special Keyword/Storage class.
If it is not the default, how would you enforce it at the caller side?
On 17.04.2012 23:27, Joseph Rushton Wakeling wrote:
On 17/04/12 20:29, Dmitry Olshansky wrote:
First things first - development of phobos is done with dmd. Just
because gdc is
(logically so) somewhat behind dmd and new compiler features are still
coming
with every release.
Fair enough. I've fo
On 17/04/12 20:47, H. S. Teoh wrote:
The convention is to create a branch for making changes, this way it's
very easy to generate pull requests on github if you ever wanted to
contribute your code to the official codebase. Branches are super-cheap
in git anyway, and you can edit source files to y
On 17/04/12 20:29, Dmitry Olshansky wrote:
First things first - development of phobos is done with dmd. Just because gdc is
(logically so) somewhat behind dmd and new compiler features are still coming
with every release.
Fair enough. I've followed the instructions here:
https://xtzgzorex.word
But C++ does not do that either.
Are you asking for a full-blown non-null type system?
Yes, but of course only with a special Keyword/Storage class.
On 04/17/2012 08:40 PM, Namespace wrote:
Define 'ensure'.
Guarantee, that the given object parameter isn't a null reference.
But C++ does not do that either.
Are you asking for a full-blown non-null type system?
On Tue, Apr 17, 2012 at 10:29:24PM +0400, Dmitry Olshansky wrote:
> On 17.04.2012 22:10, Joseph Rushton Wakeling wrote:
> >Hello all,
> >
> >As per earlier discussion I'm trying to hack on Phobos to update the
> >random sampling code.
> >
> >To do this I've just copied random.d into a new file, ran
Define 'ensure'.
Guarantee, that the given object parameter isn't a null reference.
On Tuesday, 17 April 2012 at 18:25:21 UTC, Ali Çehreli wrote:
On 04/17/2012 11:13 AM, Xan wrote:
> The idea is behind this https://gist.github.com/2407923
> But I receive:
>
> $ gdmd-4.6 algorisme_code.d
> algorisme_code.d:22: Error: variable codi cannot be read at
compile time
> algorisme_code.
On 17.04.2012 22:10, Joseph Rushton Wakeling wrote:
Hello all,
As per earlier discussion I'm trying to hack on Phobos to update the
random sampling code.
To do this I've just copied random.d into a new file, randomsample.d,
which I'm modifying and messing around with; I'm trying to build agains
On 04/17/2012 11:13 AM, Xan wrote:
> The idea is behind this https://gist.github.com/2407923
> But I receive:
>
> $ gdmd-4.6 algorisme_code.d
> algorisme_code.d:22: Error: variable codi cannot be read at compile time
> algorisme_code.d:22: Error: argument to mixin must be a string, not
(codi)
On Tuesday, April 17, 2012 20:10:51 Joseph Rushton Wakeling wrote:
> Hello all,
>
> As per earlier discussion I'm trying to hack on Phobos to update the random
> sampling code.
>
> To do this I've just copied random.d into a new file, randomsample.d, which
> I'm modifying and messing around with;
On 04/17/2012 08:10 PM, Namespace wrote:
> Best of all solutions would be that a
> special keyword, for example scope, ensure that lvalues would
except but
> _no_ null-references.
Yes, the keyword would be a little shorter than the assert() or
enforce() above but D already has very many keywords
> Best of all solutions would be that a
> special keyword, for example scope, ensure that lvalues would
except but
> _no_ null-references.
Yes, the keyword would be a little shorter than the assert() or
enforce() above but D already has very many keywords. :)
Yes, but scope is an unused storag
On Tuesday, 17 April 2012 at 18:00:55 UTC, Xan wrote:
On Tuesday, 17 April 2012 at 15:59:25 UTC, Ali Çehreli wrote:
On 04/17/2012 08:42 AM, Xan wrote:
> How to get the "code" of a function or delegate
>
> |___string toString() {
> |___|___return format("%s (versió %s): Domini -> Recorregut,
%s(
Hello all,
As per earlier discussion I'm trying to hack on Phobos to update the random
sampling code.
To do this I've just copied random.d into a new file, randomsample.d, which I'm
modifying and messing around with; I'm trying to build against a local copy of
the GitHub Phobos sources.
Wh
On Tuesday, April 17, 2012 19:22:30 André Stein wrote:
> Hi,
>
> I'm trying to pass the range returned by iota to a function accepting
> the parameter as const. I got compilation errors when trying to use the
> index operator and after some investigation it turned out that opSlice
> of iota.Result
On Tuesday, 17 April 2012 at 18:00:55 UTC, Xan wrote:
On Tuesday, 17 April 2012 at 15:59:25 UTC, Ali Çehreli wrote:
On 04/17/2012 08:42 AM, Xan wrote:
> How to get the "code" of a function or delegate
>
> |___string toString() {
> |___|___return format("%s (versió %s): Domini -> Recorregut,
%s(
On 04/17/2012 10:37 AM, Namespace wrote:
>> Yes, you must because whetheer obj is null is only known at runtime.
>
> Yes, but if i forget the assert i get an Access Violation error with no
> more informations. Problem is nobody knows _why_ he gets this error,
> because the error message gives no i
On Tuesday, 17 April 2012 at 15:59:25 UTC, Ali Çehreli wrote:
On 04/17/2012 08:42 AM, Xan wrote:
> How to get the "code" of a function or delegate
>
> |___string toString() {
> |___|___return format("%s (versió %s): Domini -> Recorregut,
%s(x) =
> %s", nom, versio, nom, &funcio);
>
> |___}
>
> d
Yes, you must because whetheer obj is null is only known at
runtime.
Yes, but if i forget the assert i get an Access Violation error
with no more informations. Problem is nobody knows _why_ he gets
this error, because the error message gives no information.
So it must be a better solution then
Hi,
I'm trying to pass the range returned by iota to a function accepting
the parameter as const. I got compilation errors when trying to use the
index operator and after some investigation it turned out that opSlice
of iota.Result isn't declared as const.
The function body of opSlice of iot
For that, you have static if contitions, and indeed you can
make it a compile-time error.
Can you show me this as code? And are there any plans to realize
non-null references or strategies to avoid such things? Otherwise
there would really be something important missing in D.
On 04/17/2012 09:12 AM, Timon Gehr wrote:
> On 04/17/2012 06:09 PM, Ali Çehreli wrote:
>> The algorithm must be building a local string.
> It does not have to build a local string, see
> http://dlang.org/phobos/std_utf.html#strideBack
I never said otherwise. :p
I was too lazy to locate where 2
On 04/17/2012 06:09 PM, Ali Çehreli wrote:
On 04/17/2012 08:58 AM, bearophile wrote:
> Ali Çehreli:
>
>> The reason is, a sequence of UTF-8 code units are not a valid UTF-8
>> when reversed (or retro'ed :p).
>
> But reversed(char[]) now works :-)
That's pretty cool. :) (You meant reverse()
On 04/17/2012 08:58 AM, bearophile wrote:
> Ali Çehreli:
>
>> The reason is, a sequence of UTF-8 code units are not a valid UTF-8
>> when reversed (or retro'ed :p).
>
> But reversed(char[]) now works :-)
That's pretty cool. :) (You meant reverse()).
Interesting, because there could be no other w
On 04/17/2012 08:42 AM, Xan wrote:
> How to get the "code" of a function or delegate
>
> |___string toString() {
> |___|___return format("%s (versió %s): Domini -> Recorregut, %s(x) =
> %s", nom, versio, nom, &funcio);
>
> |___}
>
> does not produce the desired result and &funcio without ampersan
Ali Çehreli:
The reason is, a sequence of UTF-8 code units are not a valid
UTF-8 when reversed (or retro'ed :p).
But reversed(char[]) now works :-)
Bye,
bearophile
On 04/17/2012 08:49 AM, Ali Çehreli wrote:
> That fails because null is a compile time value and you have a special
> template code for that that fails the compilation.
Scratch the 'template' part. You don't have templates there but what I
said is still valid. Basically, you have some code that
On 04/17/2012 02:39 AM, Namespace wrote:
>> Bar b = new Bar(42);
>>
>> new Foo(b); // works
>> new Foo(null); // compiler error
That fails because null is a compile time value and you have a special
template code for that that fails the compilation.
>> new Foo(Bar(23)); // works
>> new Foo(Ba
On 04/17/2012 08:12 AM, Jakob Ovrum wrote:
> Consider this simple function:
>
> private string findParameterList(string typestr)
> {
> auto strippedHead = typestr.find("(")[1 .. $];
> auto strippedTail = retro(strippedHead).find(")");
>
> strippedTail.popFront(); // slice off closing parenthesis
>
On Tuesday, 17 April 2012 at 15:30:36 UTC, Ali Çehreli wrote:
On 04/17/2012 08:17 AM, Xan wrote:
Off-topic, could can I define toString having this structure:
(versió ): ->
,
?
(For example, in https://gist.github.com/2394274 I want that
Doblar
displays as:
Doblar (versió 1): int -> in
On Tuesday, 17 April 2012 at 09:39:10 UTC, Namespace wrote:
On Tuesday, 17 April 2012 at 08:02:02 UTC, Namespace wrote:
Now i have something like this. It works and manipulates
lvalues so that i can pass my objects by ref to except null.
But is this smart?
class Bar {
public:
int x;
On 04/17/2012 08:17 AM, Xan wrote:
Off-topic, could can I define toString having this structure:
(versió ): -> ,
?
(For example, in https://gist.github.com/2394274 I want that Doblar
displays as:
Doblar (versió 1): int -> int, { return 2 * a; }
Thanks a lot,
Xan.
std.string.format is ea
On Saturday, 14 April 2012 at 10:48:16 UTC, Luis Panadero
Guardeño wrote:
What is the status of "shared" types ?
I try it with gdmd v4.6.3
And I not get any warring/error when I do anything over a
shared variable
without using atomicOp. It's normal ?
shared ushort ram[ram_size];
ram
On Tuesday, 17 April 2012 at 15:21:30 UTC, Dejan Lekic wrote:
On Tuesday, 17 April 2012 at 14:57:18 UTC, Xan wrote:
On Tuesday, 17 April 2012 at 01:31:43 UTC, Kenji Hara wrote:
On Monday, 16 April 2012 at 18:48:52 UTC, Xan wrote:
On Sunday, 15 April 2012 at 19:30:27 UTC, Ali Çehreli wrote:
On
On Tuesday, 17 April 2012 at 14:57:18 UTC, Xan wrote:
On Tuesday, 17 April 2012 at 01:31:43 UTC, Kenji Hara wrote:
On Monday, 16 April 2012 at 18:48:52 UTC, Xan wrote:
On Sunday, 15 April 2012 at 19:30:27 UTC, Ali Çehreli wrote:
On 04/15/2012 11:39 AM, Xan wrote:
> On Sunday, 15 April 2012 at
Jakob Ovrum:
return array(strippedTail);
}
The type of the return expression is dstring, not string.
What is the most elegant way or correct way to solve this
friction?
(Note: the function is used in CTFE)
Try "text" instead of "array".
Bye,
bearophile
Off-topic, could can I define toString having this structure:
(versió ): ->
,
?
(For example, in https://gist.github.com/2394274 I want that
Doblar displays as:
Doblar (versió 1): int -> int, { return 2 * a; }
Thanks a lot,
Xan.
On 4/17/12, Somedude wrote:
> Do you have any idea where this is explained
rdmd --help
Consider this simple function:
private string findParameterList(string typestr)
{
auto strippedHead = typestr.find("(")[1 .. $];
auto strippedTail = retro(strippedHead).find(")");
strippedTail.popFront(); // slice off closing parent
On Tuesday, 17 April 2012 at 01:31:43 UTC, Kenji Hara wrote:
On Monday, 16 April 2012 at 18:48:52 UTC, Xan wrote:
On Sunday, 15 April 2012 at 19:30:27 UTC, Ali Çehreli wrote:
On 04/15/2012 11:39 AM, Xan wrote:
> On Sunday, 15 April 2012 at 11:23:37 UTC, John Chapman
> wrote:
>> On Sunday, 15
On 04/17/2012 12:42 AM, Somedude wrote:
Sorry for hijacking this thread, but since you're around, I hope you'll
see this message. As a D beginner, I'm browsing through your book.
I wanted to tell you that there is something essential missing in it:
how to compile. It's actually quite hard to fin
On 04/17/2012 06:05 AM, Luis wrote:
Thanks! It's very useful.
Ali Çehreli wrote:
synchronized (job) {
*job.slice ~= appendValue;
}
So shared, at least share data across threads. And using synchronized( )
I could do lock-based access to shared data.
Yes. I've used the same Job object there
Thanks! It's very useful.
Ali Çehreli wrote:
> synchronized (job) {
> *job.slice ~= appendValue;
> }
So shared, at least share data across threads. And using synchronized( )
I could do lock-based access to shared data.
Le 17/04/2012 09:30, Somedude a écrit :
> Anyway, I think I'll add this simple piece of info somewhere in the
> wiki. I've already cleaned it up a little.
Ok, here it is: http://prowiki.org/wiki4d/wiki.cgi?HowTo/UnitTests
On Tuesday, 17 April 2012 at 12:04:44 UTC, Erèbe wrote:
[snip]
There is something I still don't understand :
mixin template Foo( T... )
{
//Code here
}
mixin Foo!( "Hello", "Word" ); < Good
T is TemplateTypeParameter, and matches any kind of template
arguments - types, values, and symbo
In this case, I had to type:
rdmd -unittest --main test.d
Without the --main, I would get linker errors, and couldn't find the
reason for these errors. Happily, someone here explained me that the
effect of the --main flag was to insert a main() function just for this
case.
That's not surprising
On Tuesday, 17 April 2012 at 10:29:56 UTC, Kenji Hara wrote:
On Tuesday, 17 April 2012 at 08:28:45 UTC, Erèbe wrote:
Hi,
I'm working on some metaprogramming code which implement a
Factory and generate an enum from a list of string.
So here my questions :
1) The documentation say mixin templ
Le 17/04/2012 12:19, Mike Parker a écrit :
> On 4/17/2012 4:42 PM, Somedude wrote:
>
>>>
>>> Ali
>>>
>>>
>> Hi Ali,
>>
>> Sorry for hijacking this thread, but since you're around, I hope you'll
>> see this message. As a D beginner, I'm browsing through your book.
>> I wanted to tell you that there
On 17.04.2012 12:28, "Erèbe" wrote:
Hi,
I'm working on some metaprogramming code which implement a Factory and
generate an enum from a list of string.
So here my questions :
1) The documentation say mixin templates could take as
TemplateParameterList
a "TemplateParameter , TemplateParameterLis
On Tuesday, 17 April 2012 at 08:28:45 UTC, Erèbe wrote:
Hi,
I'm working on some metaprogramming code which implement a
Factory and generate an enum from a list of string.
So here my questions :
1) The documentation say mixin templates could take as
TemplateParameterList
a "TemplateParameter
On 4/17/2012 4:42 PM, Somedude wrote:
Ali
Hi Ali,
Sorry for hijacking this thread, but since you're around, I hope you'll
see this message. As a D beginner, I'm browsing through your book.
I wanted to tell you that there is something essential missing in it:
how to compile. It's actually qu
On Tuesday, 17 April 2012 at 08:02:02 UTC, Namespace wrote:
Now i have something like this. It works and manipulates
lvalues so that i can pass my objects by ref to except null.
But is this smart?
class Bar {
public:
int x;
static ref Bar opCall(int x) {
Hi,
I'm working on some metaprogramming code which implement a
Factory and generate an enum from a list of string.
So here my questions :
1) The documentation say mixin templates could take as
TemplateParameterList
a "TemplateParameter , TemplateParameterList" but all my tried to
instaciate
Le 17/04/2012 08:40, Russel Winder a écrit :
> On Mon, 2012-04-16 at 21:03 +0200, Somedude wrote:
> [...]
>
> Issue 7919
>
> http://d.puremagic.com/issues/show_bug.cgi?id=7919
>
Thanks.
Now i have something like this. It works and manipulates lvalues
so that i can pass my objects by ref to except null.
But is this smart?
class Bar {
public:
int x;
static ref Bar opCall(int x) {
static Bar b;
b = new Bar(
Le 17/04/2012 02:01, Ali Çehreli a écrit :
> On 04/16/2012 04:56 PM, darkstalker wrote:
>> i have this example program:
>>
>> ---
>> void main()
>> {
>> int[3] a;
>> foreach (p; a)
>> p = 42;
>> writeln(a);
>> }
>> ---
>>
>> after running it, i expect to get [42, 42, 42] but instead i get [0, 0,
>>
Le 17/04/2012 01:26, Andrej Mitrovic a écrit :
> On 4/17/12, Somedude wrote:
>> But running the exe crashes immediately at execution with "unauthorized
>> instruction". Why ?
>
> That's the old exectuable leftover from the previous compile. RDMD
> generates the exe in a temporary folder with a ra
80 matches
Mail list logo