Re: Grokking std.container and Ranges

2010-06-28 Thread BCS
Hello Mike, I want to do the following: foreach(obj; list) { if(obj.pleaseKillMe) somehow_remove_the_object_from_the_list(); } That isn't legal for normal arrays or AAs. IIRC the docs even say that you can't change what a foreach is iterating over during the foreach. I think you will have to

Grokking std.container and Ranges

2010-06-28 Thread Mike Parker
I thought I understood ranges until I actually started trying to use them. Now I'm having difficulties with the new range-based containers. So I've got two issues right now, grokking ranges and understanding the container interfaces. Given an SList, I want to do the following: foreach(obj; li

Re: How do I make an extern function?

2010-06-28 Thread BCS
Hello Simen, module a; extern void foo( ); void bar( ) { foo( ); } module b; import std.stdio; void foo( ) { writeln( "Hi!" ); } The above does not work (Error 42: Symbol Undefined _D1a3fooFZv). Adding extern to foo in module b ch

Re: How do I make an extern function?

2010-06-28 Thread Jonathan M Davis
On Monday, June 28, 2010 17:51:09 Simen kjaeraas wrote: > > module a; > > extern void foo( ); > > void bar( ) { > foo( ); > } > > module b; > > import std.stdio; > > void foo( ) { > writeln( "Hi!" ); > } > > > The above d

Re: How do I make an extern function?

2010-06-28 Thread torhu
On 29.06.2010 02:51, Simen kjaeraas wrote: module a; extern void foo( ); void bar( ) { foo( ); } module b; import std.stdio; void foo( ) { writeln( "Hi!" ); } The above does not work (Error 42: Symbol Undefined _D1a3f

How do I make an extern function?

2010-06-28 Thread Simen kjaeraas
module a; extern void foo( ); void bar( ) { foo( ); } module b; import std.stdio; void foo( ) { writeln( "Hi!" ); } The above does not work (Error 42: Symbol Undefined _D1a3fooFZv). Adding extern to foo in module b changes

Re: What are delimited string, heredoc and D token strings?

2010-06-28 Thread Pierre Rouleau
On 27/06/10 1:03 PM, bearophile wrote: Pierre Rouleau: In what sense? This is valid D1 code: import std.stdio; void main() { string s = "this is just a test"; writefln(s); } Bye, bearophile Thanks! -- Pierre

Re: @porperty problem..

2010-06-28 Thread BLS
On 29/06/2010 00:07, Simen kjaeraas wrote: Maybe it's because you haven't added string to the setter? Just grasping at straws here. -- Simen Hi Simen, yes, thats the prob. I just have not found the @property docs.. thanks for all the help.. This snippet works now as expected.. D properties a

Re: @porperty problem..

2010-06-28 Thread Simen kjaeraas
BLS wrote: Hm, this snippet does not compile : class Server { private string _name, _id; @property servername(string name) { _name = name; } @property string servername() { return _name; } } remove string from @property

Re: @porperty problem..

2010-06-28 Thread BLS
On 28/06/2010 23:00, Steven Schveighoffer wrote: http://www.digitalmars.com/d/2.0/function.html#property-functions -Steve Makes sense :) thanks

Re: @porperty problem..

2010-06-28 Thread BLS
On 28/06/2010 22:58, Steven Schveighoffer wrote: I wasn't aware that @property implies auto. I guess that makes sense, but I didn't consider it anything but a hint to the compiler about how it could be called, not that did anything with the type. Hm, this snippet does not compile : class Serv

Re: @porperty problem..

2010-06-28 Thread Ellery Newcomer
On 06/28/2010 03:58 PM, Steven Schveighoffer wrote: On Mon, 28 Jun 2010 16:55:01 -0400, Ellery Newcomer wrote: On 06/28/2010 03:47 PM, Steven Schveighoffer wrote: On Mon, 28 Jun 2010 16:37:06 -0400, BLS wrote: @property nextServer() { Shouldn't this be @property Server nextServer() { ?

Re: @porperty problem..

2010-06-28 Thread Steven Schveighoffer
On Mon, 28 Jun 2010 16:55:44 -0400, Rory McGuire wrote: On Mon, 28 Jun 2010 22:37:06 +0200, BLS wrote: beside, where are the @property docs ? Only place I've seen @property docs is in TDPL http://www.digitalmars.com/d/2.0/function.html#property-functions -Steve

Re: @porperty problem..

2010-06-28 Thread BLS
On 28/06/2010 22:47, Steven Schveighoffer wrote: houldn't this be @property Server nextServer() { Ouch, you are right.. Interesting enough that @property nextServer() { return ...} compiles without giving any error message.. Anyway it seems to be a forward reference bug. moving the inner Se

Re: @porperty problem..

2010-06-28 Thread Ellery Newcomer
On 06/28/2010 03:47 PM, Steven Schveighoffer wrote: On Mon, 28 Jun 2010 16:37:06 -0400, BLS wrote: @property nextServer() { Shouldn't this be @property Server nextServer() { ??? auto functions?

Re: @porperty problem..

2010-06-28 Thread Steven Schveighoffer
On Mon, 28 Jun 2010 16:55:01 -0400, Ellery Newcomer wrote: On 06/28/2010 03:47 PM, Steven Schveighoffer wrote: On Mon, 28 Jun 2010 16:37:06 -0400, BLS wrote: @property nextServer() { Shouldn't this be @property Server nextServer() { ??? auto functions? I wasn't aware that @proper

Re: @porperty problem..

2010-06-28 Thread Rory McGuire
On Mon, 28 Jun 2010 22:37:06 +0200, BLS wrote: Hi I have a forward reference pb in conjunction with @property. Err msg is : forward refrence to inferred return type of function call s1.servername. any ideas ? beside, where are the @property docs ? thanks, bjoern final class LoadBalancer {

Re: Why doesn't this work in D2?

2010-06-28 Thread Jacob Carlborg
On 2010-06-28 15:48, BCS wrote: Hello Jacob, On 2010-06-28 02:28, BCS wrote: One solution would be to have templates strip off const/immutable from the top level of args. [...] This solution would match the proposal that popped up a while ago to allow value assignment from const/immutable

Re: @prorperty problem..

2010-06-28 Thread BLS
On 28/06/2010 22:37, BLS wrote: forward refrence to inferred return type of function call s1.servername. any ideas ? beside, where are the @property docs ? thanks, bjoern ok moving the inner Server class (see prev. msg) in front of LoadBalancer works.. seems to be a forward reference bug. cl

Re: @porperty problem..

2010-06-28 Thread Steven Schveighoffer
On Mon, 28 Jun 2010 16:37:06 -0400, BLS wrote: Hi I have a forward reference pb in conjunction with @property. Err msg is : forward refrence to inferred return type of function call s1.servername. any ideas ? beside, where are the @property docs ? thanks, bjoern final class LoadBalancer {

Re: @porperty problem..

2010-06-28 Thread Simen kjaeraas
BLS wrote: Hi I have a forward reference pb in conjunction with @property. Err msg is : forward refrence to inferred return type of function call s1.servername. any ideas ? No line number? If so, file it in bugzilla. You might also want to file a bug for the forward reference problems. b

@porperty problem..

2010-06-28 Thread BLS
Hi I have a forward reference pb in conjunction with @property. Err msg is : forward refrence to inferred return type of function call s1.servername. any ideas ? beside, where are the @property docs ? thanks, bjoern final class LoadBalancer { private static LoadBalancer lb; privat

Re: auto functions not authorized inside main?

2010-06-28 Thread Rory McGuire
On Mon, 28 Jun 2010 16:01:46 +0200, BCS wrote: Hello Rory, On Sun, 27 Jun 2010 17:17:25 +0200, Philippe Sigaud wrote: void main() { auto fun(string s) { return s;} // this does not compile } Hope this isn't a stupid question, but how would you access this function if it did work? Would i

Re: auto functions not authorized inside main?

2010-06-28 Thread Rory McGuire
On Mon, 28 Jun 2010 16:07:43 +0200, Philippe Sigaud wrote:On Mon, Jun 28, 2010 at 15:40, Rory McGuire wrote: void main() {    auto fun(string s) { return s;} // this does not compile } Hope this isn't a stupid question, but how would you access this function if it di

scope keyword within template mixins

2010-06-28 Thread KlausO
Hi D users, I created/tested a little logging class under DMD 1.062: //- // // helper class for debugging/logging // import std.string; import std.stdio; scope class LogEnter { static int mIndent; static char[] doindent

Re: auto functions not authorized inside main?

2010-06-28 Thread BCS
Hello Rory, On Sun, 27 Jun 2010 17:17:25 +0200, Philippe Sigaud wrote: void main() { auto fun(string s) { return s;} // this does not compile } Hope this isn't a stupid question, but how would you access this function if it did work? Would it be fun("asdf")? Is this just shorthand for: auto

Re: Why doesn't this work in D2?

2010-06-28 Thread Philippe Sigaud
On Mon, Jun 28, 2010 at 14:35, Steven Schveighoffer wrote: > On Mon, 28 Jun 2010 08:14:12 -0400, Philippe Sigaud < > philippe.sig...@gmail.com> wrote: > > On Mon, Jun 28, 2010 at 10:56, Jacob Carlborg wrote: >> >> Something to keep in mind: as of 2.04x (.045? maybe), the way UTF-8 / >> UTF-32 >>

Re: Why doesn't this work in D2?

2010-06-28 Thread BCS
Hello Jacob, On 2010-06-28 02:28, BCS wrote: One solution would be to have templates strip off const/immutable from the top level of args. [...] This solution would match the proposal that popped up a while ago to allow value assignment from const/immutable to mutable. I don't think I und

Re: auto functions not authorized inside main?

2010-06-28 Thread Rory McGuire
On Sun, 27 Jun 2010 17:17:25 +0200, Philippe Sigaud wrote: Is it defined somewhere that auto functions are not authorized inside main? void main() { auto fun(string s) { return s;} // this does not compile } error: main.d|6|found 's' when expecting ')'| main.d|6|semicolon expected, n

Re: Why doesn't this work in D2?

2010-06-28 Thread Jacob Carlborg
On 2010-06-28 14:14, Philippe Sigaud wrote: On Mon, Jun 28, 2010 at 10:56, Jacob Carlborg mailto:d...@me.com>> wrote: Something to keep in mind: as of 2.04x (.045? maybe), the way UTF-8 / UTF-32 is managed was changed. "asd" is an array of immutable(dchar), not imutable(char). At least DMD tells

Re: Why doesn't this work in D2?

2010-06-28 Thread Steven Schveighoffer
On Mon, 28 Jun 2010 08:14:12 -0400, Philippe Sigaud wrote: On Mon, Jun 28, 2010 at 10:56, Jacob Carlborg wrote: Something to keep in mind: as of 2.04x (.045? maybe), the way UTF-8 / UTF-32 is managed was changed. "asd" is an array of immutable(dchar), not imutable(char). At least DMD tel

Re: Why doesn't this work in D2?

2010-06-28 Thread Philippe Sigaud
On Mon, Jun 28, 2010 at 10:56, Jacob Carlborg wrote: Something to keep in mind: as of 2.04x (.045? maybe), the way UTF-8 / UTF-32 is managed was changed. "asd" is an array of immutable(dchar), not imutable(char). At least DMD tells me that its element type is 'dchar'. So your function can be don

Re: A module comprehensive template-specialization

2010-06-28 Thread Rory McGuire
On Mon, 28 Jun 2010 11:09:13 +0200, Matthias Walter wrote: On 06/28/2010 09:49 AM, Justin Spahr-Summers wrote: On Sun, 27 Jun 2010 18:51:35 +0200, Matthias Walter wrote: Hi list, I tried to write a traits class comparable to iterator_traits in C++ STL or graph_traits in Boost Graph Lib

Re: A module comprehensive template-specialization

2010-06-28 Thread Matthias Walter
On 06/28/2010 09:49 AM, Justin Spahr-Summers wrote: > On Sun, 27 Jun 2010 18:51:35 +0200, Matthias Walter > wrote: >> >> Hi list, >> >> I tried to write a traits class comparable to iterator_traits in C++ STL >> or graph_traits in Boost Graph Library in D 2.0, but failed to do so via >> template

Re: Why doesn't this work in D2?

2010-06-28 Thread Jacob Carlborg
On 2010-06-28 02:28, BCS wrote: Hello Jacob, That's annoying, specially since "char" is a value type. I would preferably have a solution for both D1 and D2. Can I use a template to cast/alias away the immutable part? One solution would be to have templates strip off const/immutable from the t

Re: A module comprehensive template-specialization

2010-06-28 Thread Matthias Walter
On 06/28/2010 05:32 AM, Simen kjaeraas wrote: > Matthias Walter wrote: > >> Can I handle this in another way (like making the template a conditional >> one)? > > Template constraints[1] sounds like what you want. > > Basically, you want the following: > > == Module a == > | module a; > | > | t

Re: A module comprehensive template-specialization

2010-06-28 Thread Justin Spahr-Summers
On Sun, 27 Jun 2010 18:51:35 +0200, Matthias Walter wrote: > > Hi list, > > I tried to write a traits class comparable to iterator_traits in C++ STL > or graph_traits in Boost Graph Library in D 2.0, but failed to do so via > template specialization which is put into different modules. Putting