Click here to Skip to main content
15,887,485 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: What is an Object Pin
robocodeboy2-Dec-13 4:30
robocodeboy2-Dec-13 4:30 
GeneralRe: What is an Object Pin
michaelbarb2-Dec-13 8:11
michaelbarb2-Dec-13 8:11 
GeneralRe: What is an Object Pin
Rob Grainger28-Nov-13 4:35
Rob Grainger28-Nov-13 4:35 
GeneralRe: What is an Object Pin
michaelbarb28-Nov-13 12:55
michaelbarb28-Nov-13 12:55 
GeneralRe: What is an Object Pin
Rob Grainger28-Nov-13 22:35
Rob Grainger28-Nov-13 22:35 
GeneralRe: What is an Object Pin
michaelbarb29-Nov-13 2:40
michaelbarb29-Nov-13 2:40 
GeneralRe: What is an Object Pin
Rob Grainger2-Dec-13 2:35
Rob Grainger2-Dec-13 2:35 
GeneralRe: What is an Object Pin
michaelbarb2-Dec-13 8:00
michaelbarb2-Dec-13 8:00 
GeneralRe: What is an Object Pin
Rob Grainger2-Dec-13 8:36
Rob Grainger2-Dec-13 8:36 
GeneralRe: What is an Object Pin
michaelbarb2-Dec-13 9:26
michaelbarb2-Dec-13 9:26 
GeneralRe: What is an Object Pin
Rob Grainger2-Dec-13 10:01
Rob Grainger2-Dec-13 10:01 
GeneralIf in doubt: cast, cast and cast again Pin
Mardy Git14-Nov-13 7:05
Mardy Git14-Nov-13 7:05 
GeneralRe: If in doubt: cast, cast and cast again Pin
PIEBALDconsult14-Nov-13 9:06
mvePIEBALDconsult14-Nov-13 9:06 
AnswerRe: If in doubt: cast, cast and cast again Pin
Mardy Git14-Nov-13 19:40
Mardy Git14-Nov-13 19:40 
GeneralRe: If in doubt: cast, cast and cast again Pin
ZurdoDev15-Nov-13 8:02
professionalZurdoDev15-Nov-13 8:02 
GeneralNone Pin
PIEBALDconsult1-Nov-13 11:41
mvePIEBALDconsult1-Nov-13 11:41 
GeneralRe: None PinPopular
contracting19901-Nov-13 23:58
contracting19901-Nov-13 23:58 
JokeRe: None Pin
Paulo Augusto Kunzel5-Nov-13 6:44
professionalPaulo Augusto Kunzel5-Nov-13 6:44 
GeneralRe: None Pin
contracting20135-Nov-13 22:07
contracting20135-Nov-13 22:07 
GeneralRe: None Pin
Mohamad M. Mohamad7-Nov-13 4:09
Mohamad M. Mohamad7-Nov-13 4:09 
GeneralRe: None Pin
thatraja7-Nov-13 4:38
professionalthatraja7-Nov-13 4:38 
GeneralRe: None Pin
Thanks78727-Nov-13 17:38
professionalThanks78727-Nov-13 17:38 
GeneralRe: None Pin
Keith Barrow11-Nov-13 22:29
professionalKeith Barrow11-Nov-13 22:29 
GeneralIt's taking a while but at least its working its way through that import (comments not added/edited by me) Pin
JMK8924-Oct-13 22:58
professionalJMK8924-Oct-13 22:58 
GeneralBlast you Vilmos and Your Clever Cleverness! Pin
Nagy Vilmos23-Oct-13 23:31
professionalNagy Vilmos23-Oct-13 23:31 
I have an expression evaluator and, amongst other things, I'm extending it with function definition goodness.
Each expression takes a data set as input - name value pair type thing - and uses it to return a value:
Egg:
data {
  a % 1
  b % 2 
}
expression - a + b


This would take the two values and return their sum [3 for the hard of thinking]

Now I started to get clever in defining the function to allow variable arguments and it seemed to be working well until I tried to some clever re-cursiveness:

function {
  # ~ allows the function to take unlimited arguments as it just represents the data:
  arguments - ~
  function "
    # if item 1 is null return item 0
    [isNull ~1] ?
      ~0 :
      (
        # clone the input [~ is everything]
        data = [data.clone ~];
        # remove item 0
        [data.remove data "~0"];
        # and call back... with ... a ... single ... argument
        max = [max data];
        ~0 > max ?
          ~0 :
          max
      )
  "
}

So it compares a number with a data set and goes boom. Who'd have thunk it!
Stupid Vilmos, very stupid Vilmos!

I am now in the process or rewriting so that I must pass a fixed number of arguments, but by using a data set the arguments are variable.

[edit]
After fixing it, I then found that running the full test lots of previously fine tests now fail, total WTE ensues. I check the code, I check the functions in the test script, I even extend the logging to try and find what I've changed. What I did was change the block name for common functions so they wouldn't be loaded...
speramus in juniperus


modified 24-Oct-13 6:26am.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.