Re: [Hampshire] Code style

2009-06-08 Thread The Holy ettlz
On Mon, 2009-06-08 at 11:45 +0100, Victor Churchill wrote: And in a Quantum language you would just say what the heck and execute both of them in parallel anyway ;-) Or start slow_path in another thread on another core, evaluate fast_path and its viability in the main line of execution and then

Re: [Hampshire] Code style

2009-06-08 Thread Vic
So in perl one could boil the whole thing down to my $result = ($fast_path_applicable?) $fast_path() : $slow_path() ; return $result; You can do the same in C - what comes out of the compiler is identical to the simple if idiom I used earlier. So - for clarity - I'd still go for that one...

Re: [Hampshire] Code style

2009-06-08 Thread Hugo Mills
On Mon, Jun 08, 2009 at 11:45:29AM +0100, Victor Churchill wrote: On Hugo's second question, well yes different languages have different capabilities. So in perl one could boil the whole thing down to my $result = ($fast_path_applicable?) $fast_path() : $slow_path() ; return $result;

Re: [Hampshire] Code style

2009-06-08 Thread Damian Brasher
Hugo Mills wrote: If you were writing a function with a fast path and a slow path, which style would you use to write the function? Style A: if can_use_fast_path: return fast path result # do slow stuff return slow path result Style B: result = fast path result if

Re: [Hampshire] Code style

2009-06-08 Thread Daniel Pope
Hugo Mills wrote: I happily thought that the ternary operator had been put to death in Python, until I saw this little gem in some code yesterday: (is_forward and F or B) The perpetrator has been given a good talking-to. :) That's become a common idiom in Python, and most

Re: [Hampshire] Code style

2009-06-08 Thread Hugo Mills
On Mon, Jun 08, 2009 at 02:53:12PM +0100, Daniel Pope wrote: Hugo Mills wrote: I happily thought that the ternary operator had been put to death in Python, until I saw this little gem in some code yesterday: (is_forward and F or B) The perpetrator has been given a good

Re: [Hampshire] Code style

2009-06-08 Thread Daniel Pope
Vic wrote: Style A has multiple returns from the function. That's one of those things that's just fine right up until it isn't; code grows as different people work on it, and sooner or later, you can't see both returns on the same page. That's when mistakes happen. Totally disagree with that.

Re: [Hampshire] Code style

2009-06-08 Thread Vic
I'm not a fan of the whole concept. I've rarely met a use of the ternary operator, in any language, that made code easier to read.) They can be very useful : ArrayStart = StartsWithZero ? 0 : 1 ; Or even : #define min(a, b) ((ab) ? a : b ) But, as with so many things, ternary operators

Re: [Hampshire] Code style

2009-06-08 Thread Bob Dunlop
Hi, On Mon, Jun 08 at 02:57, Hugo Mills wrote: ... Yet one more reason to avoid ternary operators... (If you haven't guessed yet, I'm not a fan of the whole concept. I've rarely met a use of the ternary operator, in any language, that made code easier to read.) So I guess you wouldn't be

Re: [Hampshire] Code style

2009-06-08 Thread Hugo Mills
On Mon, Jun 08, 2009 at 03:09:49PM +0100, Vic wrote: I'm not a fan of the whole concept. I've rarely met a use of the ternary operator, in any language, that made code easier to read.) They can be very useful : ArrayStart = StartsWithZero ? 0 : 1 ; Or even : #define min(a, b)

Re: [Hampshire] Code style

2009-06-08 Thread Daniel Pope
Hugo Mills wrote: result = 1 if test() else -1 the idea being that the difference in syntax stresses the success path as the default with the failure path as a fallback. Eww. That's *intensely* ugly. I felt the same way the first time I saw it, but actually encountering it it's really

Re: [Hampshire] Code style

2009-06-08 Thread Victor Churchill
I'm not a fan of the whole concept. I've rarely met a use of the ternary operator, in any language, that made code easier to read.) I'd better not reveal some of my code then ;-) I have been known to hang ternaries inside me ternaries on occasion. A quick scan for \?.*: finds one usage

Re: [Hampshire] Code style

2009-06-08 Thread Isaac Close
--- On Mon, 8/6/09, Hugo Mills h...@carfax.org.uk wrote: On Mon, Jun 08, 2009 at 02:53:12PM +0100, Daniel Pope wrote: result = 1 if test() else -1 the idea being that the difference in syntax stresses the success path as the default with the failure path as a fallback.    Eww.

Re: [Hampshire] Code style

2009-06-08 Thread Hugo Mills
On Mon, Jun 08, 2009 at 03:50:47PM +, Isaac Close wrote: --- On Mon, 8/6/09, Hugo Mills h...@carfax.org.uk wrote: On Mon, Jun 08, 2009 at 02:53:12PM +0100, Daniel Pope wrote: result = 1 if test() else -1 the idea being that the difference in syntax stresses the success path

Re: [Hampshire] Code style

2009-06-08 Thread Anton Piatek
2009/6/8 Hugo Mills h...@carfax.org.uk: On Mon, Jun 08, 2009 at 03:50:47PM +, Isaac Close wrote: --- On Mon, 8/6/09, Hugo Mills h...@carfax.org.uk wrote: On Mon, Jun 08, 2009 at 02:53:12PM +0100, Daniel Pope wrote: result = 1 if test() else -1 the idea being that the

Re: [Hampshire] Code style

2009-06-08 Thread Simon Reap
Hugo Mills wrote: On Mon, Jun 08, 2009 at 03:09:49PM +0100, Vic wrote: #define min(a, b) ((ab) ? a : b ) I'll live with this use. Concise, readable (once), and above all hidden from view at the point of use. Until someone does min (a++, b++) and wonders

Re: [Hampshire] Code style

2009-06-08 Thread Stephen Rowles
Hugo Mills wrote: Yet one more reason to avoid ternary operators... (If you haven't guessed yet, I'm not a fan of the whole concept. I've rarely met a use of the ternary operator, in any language, that made code easier to read.) Hugo. I use the following fairly regularly when

[Hampshire] Computer monitor strange behaviour

2009-06-08 Thread Owain Clarke
I have an old style computer monitor - probably 6 or 7 years old - which has recently begun behaving oddly. It suddenly goes a deep purple colour. It can be revived by going onto a virtual terminal then switching back. It's on a dual boot Linux and Windows computer and happens on both, so I

Re: [Hampshire] Computer monitor strange behaviour

2009-06-08 Thread Andy Random
On Mon, 8 Jun 2009, Owain Clarke wrote: I have an old style computer monitor - probably 6 or 7 years old - By old style you mean CRT? All in all I assume my monitor is dying, but I just thought I'd ask if it sounds familiar to anyone, so I don't have to buy a new one before I have to.

Re: [Hampshire] Computer monitor strange behaviour

2009-06-08 Thread Paul Stimpson
Hi, Sounds like the green gun or the drive to it is going and that whatever the monitor does when it changes scan rate (the terminal and desktop probably use different modes) looks like it's causing the drive to the green to come back. I'd say it was probably time for a nice new flat screen.

[Hampshire] Ergo Microlite xl 1.4Ghz

2009-06-08 Thread Phillip Chandler
Hi All Has anyone had any fun with the above laptop ? Just picked one up 2nd hand, tried booting off a Ubuntu 7.10 CD. It gets as far as the menu for the typical options like :- Running from CD Installing, test memory OEM install etc. After selecting the options to either run from CD or

Re: [Hampshire] Ergo Microlite xl 1.4Ghz

2009-06-08 Thread Phillip Chandler
On Mon, 2009-06-08 at 22:01 +0100, Sean Gibbins wrote: Phillip Chandler wrote: Hi All Has anyone had any fun with the above laptop ? Just picked one up 2nd hand, tried booting off a Ubuntu 7.10 CD. ---8--- Im now installing Win XP which has formatted the HDD and is now copying

Re: [Hampshire] Ergo Microlite xl 1.4Ghz

2009-06-08 Thread Sean Gibbins
Phillip Chandler wrote: Hi All Has anyone had any fun with the above laptop ? Just picked one up 2nd hand, tried booting off a Ubuntu 7.10 CD. ---8--- Im now installing Win XP which has formatted the HDD and is now copying files. So wondered if these Ergo machines were not very happy

Re: [Hampshire] Ergo Microlite xl 1.4Ghz

2009-06-08 Thread Sean Gibbins
Phillip Chandler wrote: On Mon, 2009-06-08 at 22:01 +0100, Sean Gibbins wrote: Phillip Chandler wrote: Hi All Has anyone had any fun with the above laptop ? Just picked one up 2nd hand, tried booting off a Ubuntu 7.10 CD. ---8--- Im now installing Win XP which

Re: [Hampshire] Ergo Microlite xl 1.4Ghz

2009-06-08 Thread Andy Random
On Mon, 8 Jun 2009, Tim wrote: If you only have 256mb memory then maybe xbuntu would be a better choice? Or even crunchbang which has been recommended previously on the list as a low memory version of Ubuntu: http://crunchbanglinux.org Andy -- Please post to:

Re: [Hampshire] Computer monitor strange behaviour

2009-06-08 Thread Vic
I have an old style computer monitor - probably 6 or 7 years old - which has recently begun behaving oddly. It suddenly goes a deep purple colour. It's probably the monitor dying - but before you bin it, *check* it's not something silly like the cable starting to fall out... Vic. --