From: darren kirby Date: 2007-09-02T02:59:22+09:00 Subject: Re: Method names and alias quoth the Phrogz: > On Aug 31, 1:47 pm, darren kirby wrote: > > My code would be considerably DRYer if I could make 'load_byte_unsigned' > > an alias to 'load_byte', and have the method inspect the name it was > > called as to decide if it should run 'bitstring_to_int(byte, > > signed=false)' or not. > > > > Is there a way to do this? > > I can't offer you a way to do this, but: > > If not, I suppose my best bet is to move the snipped 15 lines to > > a 'load_byte_common' method and make 'load_byte' and 'load_byte_unsigned' > > thin wrappers around it? > > I'd personally do something like: > > def load_byte( byte, unsigned=false ) > #...your code here... > end > > def load_byte_unsigned( byte ) > load_byte( byte, true ) > end Thanks Phrogz, This gives me some ideas on how to clean up the code a bit. @Hemant: I guess I was hoping there may have been some "if self.name == "load_byte" magic that I could have used. @Pena: Thanks, but I cannot change the name of the method, that is, there must be an unsigned counterpart, as I am writing methods which emulate Mips32 ISA and I want my methods to match the ops...the real methos names are 'lb, and 'lbu' so... -d -- darren kirby :: Part of the problem since 1976 :: http://badcomputer.org "...the number of UNIX installations has grown to 10, with more expected..." - Dennis Ritchie and Ken Thompson, June 1972