Self ?

BlitzMax Forums/BlitzMax Beginners Area/Self ?

H&K(Posted 2006) [#1]
	Method Allocate:TLED (Position:TBiFloat,Size:Float,Color:TRGB,Shape:TShape,Rotation:Int = 0)

		Self.TimeSinceChange	= 0
		Self.Shape		= Shape
		Self.Position	 	= Position.CopyCreate()
		Self.Color 		= Color
		Self.Size  		= Size
		Self.Rotation 		= Rotation
		Self.IsItOn		= False
		
		Return Self	
	
	End Method

Question: Does self slow down the compiler, have no effect, or infact make it more efficient?

Reason: Ive started to use BLide as my main editor*, and really like the Object popup with all the methods/functions fields that happens when you press . **,
And so in my Methods, because Im a bit forgetful I always start the call to a member function with Self. ***
I also**** Name all the parameters, with the names of what they are going to be

And I would like to know if this is bad practice.

* All these people wondering what 3d wrapper/engine to use, and I cannot even decide which ide ;(

** Like in Protean when you press \ to get a field list

*** I Dont need to remember anything, Its Brill

**** I Have to remember even less, its Brill


Who was John Galt?(Posted 2006) [#2]
It would make little or no difference either way - time how long it takes to do a build. The compiled code would be identical I'll wager.


H&K(Posted 2006) [#3]
Ill Just take you word for it.

Thanks

Edit: However, I am going to hold you leagally responsable


ImaginaryHuman(Posted 2006) [#4]
In your code above you don't need to use Self at all, except for the Return. Since you're in a Method, all the fields of the instance of that object are available for direct use.

TimeSinceChange=0

would do just the same. Unless maybe you have similarly-named methods in parent type or something that you're trying to avoid?


H&K(Posted 2006) [#5]
@Angel, I know I dont need them,
(Well actualy in the post above I do need them, because the parameters have the same name as the fields),
The question is, being that I AM putting them in, would the compiler/Code run better/Worse.


Dreamora(Posted 2006) [#6]
No it makes no difference as the compiler makes the same out of it.

Its only for specifying the var space if you have similarily named fields / methods


Who was John Galt?(Posted 2006) [#7]
Edit: However, I am going to hold you leagally responsable

WHY I OUTTA.... ; )


bradford6(Posted 2006) [#8]
this is giving me a self.headache!


Dreamora(Posted 2006) [#9]
You mean other.makeHeadache(self) ? :-)