Jump to page: 1 2
Thread overview
@porperty problem..
Jun 28, 2010
BLS
Jun 28, 2010
Simen kjaeraas
Jun 28, 2010
Ellery Newcomer
Jun 28, 2010
Ellery Newcomer
Jun 28, 2010
BLS
Jun 28, 2010
Simen kjaeraas
Jun 28, 2010
BLS
Jun 28, 2010
BLS
Re: @prorperty problem..
Jun 28, 2010
BLS
Jun 28, 2010
Rory McGuire
Jun 28, 2010
BLS
June 28, 2010
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;
	private Server[] servers;
	
	static this() {
		synchronized lb = new LoadBalancer;
	}
	
	private this() {
		Server s1 = new Server();
		s1.servername = "Server 1";  // ERROR
		servers ~= s1;
	}
	
	public static LoadBalancer getLoadBalancer() {
      return lb;
    }

	@property nextServer() {
		return servers[0];
	}
		
	class Server {
		private string _name, _id;
		
		@property servername(string name) {
			_name = name;
		}
		@property servername() {
			return _name;
		}
	}
}
June 28, 2010
 BLS <windevguy@hotmail.de> 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.


>  beside, where are the @property docs ?

No idea.


This:
> 	@property nextServer() {
> 		return servers[0];
> 	}
Needs to be @property Server nextServer(). I don't know for sure, but
I believe @property does not cause type inference.


=> @property void servername(string name)
> 		@property servername(string name) {
> 			_name = name;
> 		}


=> @property string servername()
> 		@property servername() {
> 			return _name;
> 		}

-- 
Simen
June 28, 2010
On Mon, 28 Jun 2010 16:37:06 -0400, BLS <windevguy@hotmail.de> 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 {
> 	private static LoadBalancer lb;
> 	private Server[] servers;
> 	
> 	static this() {
> 		synchronized lb = new LoadBalancer;
> 	}
> 	
> 	private this() {
> 		Server s1 = new Server();
> 		s1.servername = "Server 1";  // ERROR
> 		servers ~= s1;
> 	}
> 	
> 	public static LoadBalancer getLoadBalancer() {
>        return lb;
>      }
>
> 	@property nextServer() {

Shouldn't this be

@property Server nextServer() {

???

> 		return servers[0];
> 	}
> 		
> 	class Server {
> 		private string _name, _id;
> 		
> 		@property servername(string name) {
> 			_name = name;
> 		}
> 		@property servername() {
> 			return _name;
> 		}
> 	}
> }

-Steve
June 28, 2010
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.

class Server {
	private string _name, _id;
		
	@property servername(string name) {
		_name = name;
	}
	@property servername() {
		return _name;
	}
}
final class LoadBalancer {
	private static LoadBalancer lb;
	private Server[] servers;
	
	static this() {
		synchronized lb = new LoadBalancer;
	}
	
	private this() {
		Server s1 = new Server();
		s1.servername = "Server 1";  // NO PROBLEM
	}
...	

}

June 28, 2010
On 06/28/2010 03:47 PM, Steven Schveighoffer wrote:
> On Mon, 28 Jun 2010 16:37:06 -0400, BLS <windevguy@hotmail.de> wrote:
>>
>> @property nextServer() {
>
> Shouldn't this be
>
> @property Server nextServer() {
>
> ???
>

auto functions?
June 28, 2010
On Mon, 28 Jun 2010 22:37:06 +0200, BLS <windevguy@hotmail.de> 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 {
> 	private static LoadBalancer lb;
> 	private Server[] servers;
> 	
> 	static this() {
> 		synchronized lb = new LoadBalancer;
> 	}
> 	
> 	private this() {
> 		Server s1 = new Server();
> 		s1.servername = "Server 1";  // ERROR
> 		servers ~= s1;
> 	}
> 	
> 	public static LoadBalancer getLoadBalancer() {
>        return lb;
>      }
>
> 	@property nextServer() {
> 		return servers[0];
> 	}
> 		
> 	class Server {
> 		private string _name, _id;
> 		
> 		@property servername(string name) {
> 			_name = name;
> 		}
> 		@property servername() {
> 			return _name;
> 		}
> 	}
> }

Only place I've seen @property docs is in TDPL
June 28, 2010
On Mon, 28 Jun 2010 16:55:01 -0400, Ellery Newcomer <ellery-newcomer@utulsa.edu> wrote:

> On 06/28/2010 03:47 PM, Steven Schveighoffer wrote:
>> On Mon, 28 Jun 2010 16:37:06 -0400, BLS <windevguy@hotmail.de> wrote:
>>>
>>> @property nextServer() {
>>
>> Shouldn't this be
>>
>> @property Server nextServer() {
>>
>> ???
>>
>
> auto functions?

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.

But I guess it's similar to static...

-Steve
June 28, 2010
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 Server() class in front of LoadBalancer eliminates the error msg.

bjoern
June 28, 2010
On Mon, 28 Jun 2010 16:55:44 -0400, Rory McGuire <rmcguire@neonova.co.za> wrote:

> On Mon, 28 Jun 2010 22:37:06 +0200, BLS <windevguy@hotmail.de> 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
June 28, 2010
On 06/28/2010 03:58 PM, Steven Schveighoffer wrote:
> On Mon, 28 Jun 2010 16:55:01 -0400, Ellery Newcomer
> <ellery-newcomer@utulsa.edu> wrote:
>
>> On 06/28/2010 03:47 PM, Steven Schveighoffer wrote:
>>> On Mon, 28 Jun 2010 16:37:06 -0400, BLS <windevguy@hotmail.de> wrote:
>>>>
>>>> @property nextServer() {
>>>
>>> Shouldn't this be
>>>
>>> @property Server nextServer() {
>>>
>>> ???
>>>
>>
>> auto functions?
>
> 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.
>
> But I guess it's similar to static...
>
> -Steve

There are a bunch of modifiers that do.

protection modifiers and maybe align and a few others don't, but pretty much everything else does
« First   ‹ Prev
1 2