On Thursday, 11 July 2013 at 03:06:39 UTC, Meta wrote:
struct Option(T)
{
Algebraic!(Some!T, None) payload;
alias payload this;
}
This is untested but it probably looks something like this:
private alias MaybeType = Algebraic!(Some!T, None);
Option!int ans;
ans.payload = Mayb
I've been playing around with std.variant.Algebraic, trying to
define a very simple option type. However, I've been running into
quite a few problems. My implementation is as follows:
import std.conv;
import std.variant;
struct Some(T)
{
T payload;
alias payload this;
}
struct None
{
On Wednesday, 10 July 2013 at 18:22:24 UTC, Ali Çehreli wrote:
And to be pedantic, length comes first:
struct Array (T)
{
size_t length;
T* ptr;
}
Which is actually property-like because assigning to length
does pretty complex stuff. So the member cannot be named as
'length':
struct
On Wed, Jul 10, 2013 at 6:16 PM, Jonathan M Davis wrote:
> On Wednesday, July 10, 2013 18:10:42 Timothee Cour wrote:
> > On Wed, Jul 10, 2013 at 5:49 PM, Artur Skawina
> wrote:
> > > On 07/11/13 00:52, Timothee Cour wrote:
> > > > Why not support Tuple indexing and slicing with [] syntax?
> > > >
On Wednesday, 10 July 2013 at 17:18:09 UTC, JohnnyK wrote:
export string mytest(string tstStr)
{
string st = tstStr;
/* abbreviated to protect the innocent but other operations
such as concatenating and deleting may be done to st
before the return
*/
return st;
}
Arrays are comp
On Thu, Jul 11, 2013 at 03:24:05AM +0200, Adam D. Ruppe wrote:
> On Wednesday, 10 July 2013 at 18:10:19 UTC, Sean Kelly wrote:
> >It would have to be done in a way that avoided allocating though
> >(similar to core.demangle), to be in core.
>
> This would be really easy to do if enum string[] = [.
On Wednesday, 10 July 2013 at 18:10:19 UTC, Sean Kelly wrote:
It would have to be done in a way that avoided allocating
though (similar to core.demangle), to be in core.
This would be really easy to do if enum string[] = [...]; didn't
allocate at runtime.
Unbelievable.
On Wednesday, July 10, 2013 18:10:42 Timothee Cour wrote:
> On Wed, Jul 10, 2013 at 5:49 PM, Artur Skawina wrote:
> > On 07/11/13 00:52, Timothee Cour wrote:
> > > Why not support Tuple indexing and slicing with [] syntax?
> > >
> > > (see below for a way to index/slice a tuple)
> >
> > Not sure
On Wed, Jul 10, 2013 at 5:49 PM, Artur Skawina wrote:
> On 07/11/13 00:52, Timothee Cour wrote:
> > Why not support Tuple indexing and slicing with [] syntax?
> > (see below for a way to index/slice a tuple)
>
> Not sure I understand the question.
> I guess you'd like this to work for some libra
On 07/11/13 00:52, Timothee Cour wrote:
> Why not support Tuple indexing and slicing with [] syntax?
> (see below for a way to index/slice a tuple)
Not sure I understand the question.
I guess you'd like this to work for some library pseudo-tuple type
- I've not looked at those, somebody else may
Ali Çehreli:
That would be great but there are many other cases where the
compiler does not do anything like that. Here, it would have to
decide similar to "even though this is a runtime foreach, I
know at compile time that 'result' is a fixed-length array so
'i' is between 0 and 10. I also h
On 07/10/2013 04:10 PM, bearophile wrote:
> Ali Çehreli:
>
>> Change the code so that the result does not fit a ubyte you will get
>> the same error as in line 11.
>
> The result is supposed to fit in an ubyte because the input is supposed
> to be made of nibbles.
Not in either of the two cases
Timothee Cour:
Why not support Tuple indexing and slicing with [] syntax?
You need a syntax like:
a.slice!(1, 3);
I don't know why Walter didn't add support for a slicing syntax
for tuples. But it's an additive change, so it's not too much
late to add it, if it's feasible.
If D will grow
Ali Çehreli:
Change the code so that the result does not fit a ubyte you
will get the same error as in line 11.
The result is supposed to fit in an ubyte because the input is
supposed to be made of nibbles. (I have tried to add asserts or
tests, but they don't change the situation, so I have
On 07/10/2013 03:08 PM, bearophile wrote:
> Do you know why the assignment to 'item' is accepted in the first case
> and refused in the second?
>
>
> ubyte generate1(s...)() {
> ubyte[10] result;
> foreach (immutable i, ref item; result)
> item = s[0][0] << 4;
s[0][0] is known
Why not support Tuple indexing and slicing with [] syntax?
(see below for a way to index/slice a tuple)
void main(){
alias T=Tuple!(int,double);
pragma(msg,T[0].stringof);//_expand_field_0
//pragma(msg,T[0..2].stringof); //Error: cannot slice type 'Tuple!(int,
double)
pragma(msg,typeof(T.
Do you know why the assignment to 'item' is accepted in the first
case and refused in the second?
ubyte generate1(s...)() {
ubyte[10] result;
foreach (immutable i, ref item; result)
item = s[0][0] << 4;
return result[0];
}
ubyte generate2(s...)() {
ubyte[10] result;
On Wednesday, July 10, 2013 13:19:33 H. S. Teoh wrote:
> How do you coax different versions of dmd to pick up a different
> dmd.conf file? The last time I tried it, all of them insisted on reading
> /etc/dmd.conf, which, of course, only actually works for one.
To quote the website (http://dlang.or
On Wednesday, 10 July 2013 at 20:21:10 UTC, H. S. Teoh wrote:
On Wed, Jul 10, 2013 at 09:40:57PM +0200, monarch_dodra wrote:
More questions related to running on ubuntu. I'd like to have
side
by side installs of dmd. Eg 2.060, 2.061 ...
I installed using the downloadable packages.
dmd and rdm
On Wednesday, 10 July 2013 at 19:40:58 UTC, monarch_dodra wrote:
More questions related to running on ubuntu. I'd like to have
side by side installs of dmd. Eg 2.060, 2.061 ...
I installed using the downloadable packages.
dmd and rdmd are in /usr/bin
druntime and phobos are in dmd, which is in
On 07/10/13 21:36, monarch_dodra wrote:
> On Tuesday, 9 July 2013 at 00:06:11 UTC, Artur Skawina wrote:
>> That plus a non-existing this._input, results in a bit (too much)
>> magic, and the first test passes. The other one fails because of
>> the '$' (ie opDollar() call).
> In any case, it is now
On Wednesday, 10 July 2013 at 17:18:09 UTC, JohnnyK wrote:
I hope you like the subject matter and I hope it is not too
simplistic or have been answered before.
Anyway I have a question about how the garbage collector
works in a very specific situation. When passing string type
to a function
On Wed, Jul 10, 2013 at 09:40:57PM +0200, monarch_dodra wrote:
> More questions related to running on ubuntu. I'd like to have side
> by side installs of dmd. Eg 2.060, 2.061 ...
>
> I installed using the downloadable packages.
>
> dmd and rdmd are in /usr/bin
> druntime and phobos are in dmd, wh
On Wednesday, 10 July 2013 at 18:45:56 UTC, H. S. Teoh wrote:
On Wed, Jul 10, 2013 at 08:38:40PM +0200, JohnnyK wrote:
[...]
Reminds me of how Delphi (aka Pascal) strings are work. Thanks
everyone this answers some of my questions. Now what about
when the
return type of a function is a string
On Wednesday, July 10, 2013 20:38:40 JohnnyK wrote:
> Reminds me of how Delphi (aka Pascal) strings are work. Thanks
> everyone this answers some of my questions. Now what about when
> the return type of a function is a string? Is D returning the
> pointer to the string structure or is it returning
More questions related to running on ubuntu. I'd like to have
side by side installs of dmd. Eg 2.060, 2.061 ...
I installed using the downloadable packages.
dmd and rdmd are in /usr/bin
druntime and phobos are in dmd, which is in /usr/include
Currently, I have 2.063 installed, and would like t
On Tuesday, 9 July 2013 at 00:06:11 UTC, Artur Skawina wrote:
That plus a non-existing this._input, results in a bit (too
much)
magic, and the first test passes. The other one fails because of
the '$' (ie opDollar() call).
artur
In any case, it is now filed:
http://d.puremagic.com/issues/show
On Wednesday, 10 July 2013 at 19:03:22 UTC, Timothee Cour wrote:
How would that work, since this is runtime only?
Take a pointer with the right type and then attach the rest of
the name to it. Given:
int foo(int a, string) { return a;}
void main() {
int function(int, string) fooPtr;
On Wed, Jul 10, 2013 at 11:39 AM, Adam D. Ruppe
wrote:
> On Wednesday, 10 July 2013 at 17:44:51 UTC, Timothee Cour wrote:
>
>> * One use case is using it in shared libraries:
>> user asks for a symbol via its demangled string representation (which is
>> most natural for user), then the string is m
On Wed, Jul 10, 2013 at 08:38:40PM +0200, JohnnyK wrote:
[...]
> Reminds me of how Delphi (aka Pascal) strings are work. Thanks
> everyone this answers some of my questions. Now what about when the
> return type of a function is a string? Is D returning the pointer
> to the string structure or i
On Wed, Jul 10, 2013 at 07:45:25PM +0200, Namespace wrote:
> >A string in D, and all arrays, is a struct looking like this:
> >
> >struct Array (T)
> >{
> >T* ptr;
> >size_t length;
> >}
>
> I always thought it looks like this:
>
> struct Array(T) {
> T* ptr;
> size_t length, capa
On Wednesday, 10 July 2013 at 17:44:51 UTC, Timothee Cour wrote:
* One use case is using it in shared libraries:
user asks for a symbol via its demangled string representation
(which is most natural for user), then the string is mangled,
and then calls dlsym to retrieve the actual pointer to sy
On Wednesday, 10 July 2013 at 18:22:24 UTC, Ali Çehreli wrote:
On 07/10/2013 11:10 AM, Sean Kelly wrote:
> On Jul 10, 2013, at 10:45 AM, Namespace
wrote:
>
>>> A string in D, and all arrays, is a struct looking like
this:
>>>
>>> struct Array (T)
>>> {
>>> T* ptr;
>>> size_t length;
>>>
On Mon, Jul 8, 2013 at 2:00 AM, bearophile wrote:
> JS:
>
>
> I think when the code is compiled a "report" can be generated listing the
>> priorities along with the locations in the file would be beneficial...
>>
>
> It looks like a useful thing, on the other hand I think most people solve
> thi
On 07/10/2013 11:10 AM, Sean Kelly wrote:
> On Jul 10, 2013, at 10:45 AM, Namespace wrote:
>
>>> A string in D, and all arrays, is a struct looking like this:
>>>
>>> struct Array (T)
>>> {
>>> T* ptr;
>>> size_t length;
>>> }
>>
>> I always thought it looks like this:
>>
>> struct Array
On Jul 10, 2013, at 10:45 AM, Namespace wrote:
>> A string in D, and all arrays, is a struct looking like this:
>>
>> struct Array (T)
>> {
>>T* ptr;
>>size_t length;
>> }
>
> I always thought it looks like this:
>
> struct Array(T) {
>T* ptr;
>size_t length, capacity;
> }
Sad
On Jul 10, 2013, at 10:44 AM, Timothee Cour wrote:
> Thanks much, that's a good start.
> Template support would definitely be needed as it's so common.
> This should go in std.demangle (or maybe a new std.mangle)
core.mangle/demangle. It would have to be done in a way that avoided
allocating t
On Tue, Jul 2, 2013 at 5:52 AM, bearophile wrote:
> Adam D. Ruppe:
>
>
> The older std.c is kept around just for compatibility with the old names
>> before the move, at least as far as I know. Maybe they haven't fully
>> deprecated it though because there's other reasons I don't know about,
>> s
A string in D, and all arrays, is a struct looking like this:
struct Array (T)
{
T* ptr;
size_t length;
}
I always thought it looks like this:
struct Array(T) {
T* ptr;
size_t length, capacity;
}
On Wed, Jul 10, 2013 at 10:30 AM, Adam D. Ruppe
wrote:
> On Wednesday, 10 July 2013 at 16:30:25 UTC, Timothee Cour wrote:
>
>> Do you have a pointer for that function in dmd ?
>>
>
> The compiler doesn't do it as one function, I mean it can parse as string
> and mangle it in the process of compili
Thanks much, that's a good start.
Template support would definitely be needed as it's so common.
This should go in std.demangle (or maybe a new std.mangle)
* One use case is using it in shared libraries:
user asks for a symbol via its demangled string representation (which is
most natural for user
On 2013-07-10 19:18, JohnnyK wrote:
I hope you like the subject matter and I hope it is not too simplistic
or have been answered before.
Anyway I have a question about how the garbage collector works in a
very specific situation. When passing string type to a function in a
shared library or D
On Wednesday, 10 July 2013 at 16:30:25 UTC, Timothee Cour wrote:
Do you have a pointer for that function in dmd ?
The compiler doesn't do it as one function, I mean it can parse
as string and mangle it in the process of compiling code.
To go from demangled string => mangled string, you'd fir
I hope you like the subject matter and I hope it is not too
simplistic or have been answered before.
Anyway I have a question about how the garbage collector works
in a very specific situation. When passing string type to a
function in a shared library or DLL and assigning it to a
variable o
On Wed, Jul 10, 2013 at 9:11 AM, Adam D. Ruppe wrote:
> As far as I know, no such function exists (outside of dmd itself).
>
Do you have a pointer for that function in dmd ?
Again, I'm not talking about
symbol => mangled string
but about
demangled string=> mangled string
As far as I know, no such function exists (outside of dmd itself).
ping?
On Wed, Jul 3, 2013 at 5:42 PM, Timothee Cour wrote:
> I'd like to have a function:
> string mangle(string mangled_string);
> unittest{
> void foo(int x){}
> assert(foo.mangleof.demangle.mangle == foo.mangleof);
> }
>
> is there such a functionality, even partially?
>
>
>
On 07/07/2013 01:22 PM, John Colvin wrote:
On Sunday, 7 July 2013 at 19:55:26 UTC, QAston wrote:
I have a large enum in my code (opcodes for a protocol) - using
std.traits.EnumMembers gives me a recursive template error.
How can i increase max number recursive template expansions?
I don't thi
48 matches
Mail list logo