Click here to Skip to main content
15,126,567 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.

 
JokeRe: None Pin
Paulo Augusto Kunzel5-Nov-13 7:44
professionalPaulo Augusto Kunzel5-Nov-13 7:44 
GeneralRe: None Pin
contracting20135-Nov-13 23:07
Membercontracting20135-Nov-13 23:07 
GeneralRe: None Pin
Mohamad M. Mohamad7-Nov-13 5:09
MemberMohamad M. Mohamad7-Nov-13 5:09 
GeneralRe: None Pin
thatraja7-Nov-13 5:38
professionalthatraja7-Nov-13 5:38 
GeneralRe: None Pin
Thanks78727-Nov-13 18:38
professionalThanks78727-Nov-13 18:38 
GeneralRe: None Pin
Keith Barrow11-Nov-13 23:29
professionalKeith Barrow11-Nov-13 23: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 23:58
professionalJMK8924-Oct-13 23:58 
GeneralBlast you Vilmos and Your Clever Cleverness! Pin
Nagy Vilmos24-Oct-13 0:31
professionalNagy Vilmos24-Oct-13 0: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.

GeneralRe: Blast you Vilmos and Your Clever Cleverness! Pin
PIEBALDconsult24-Oct-13 18:42
professionalPIEBALDconsult24-Oct-13 18:42 
GeneralLets poll no matter what time of the day PinPopular
virang_2123-Oct-13 14:01
Membervirang_2123-Oct-13 14:01 
GeneralRe: Lets poll no matter what time of the day Pin
Bernhard Hiller23-Oct-13 21:51
MemberBernhard Hiller23-Oct-13 21:51 
GeneralRe: Lets poll no matter what time of the day Pin
Kornfeld Eliyahu Peter23-Oct-13 22:02
professionalKornfeld Eliyahu Peter23-Oct-13 22:02 
GeneralRe: Lets poll no matter what time of the day Pin
OriginalGriff23-Oct-13 22:25
mveOriginalGriff23-Oct-13 22:25 
GeneralI don't know how to label this pattern. Pin
Andy Brummer23-Oct-13 12:54
sitebuilderAndy Brummer23-Oct-13 12:54 
GeneralRe: I don't know how to label this pattern. Pin
Brisingr Aerowing23-Oct-13 13:54
professionalBrisingr Aerowing23-Oct-13 13:54 
GeneralRe: I don't know how to label this pattern. Pin
Andy Brummer23-Oct-13 16:58
sitebuilderAndy Brummer23-Oct-13 16:58 
GeneralRe: I don't know how to label this pattern. Pin
Freak3023-Oct-13 23:43
MemberFreak3023-Oct-13 23:43 
GeneralCatastrophic Failure! Pin
Brisingr Aerowing18-Oct-13 12:15
professionalBrisingr Aerowing18-Oct-13 12:15 
GeneralRe: Catastrophic Failure! Pin
PIEBALDconsult18-Oct-13 14:27
professionalPIEBALDconsult18-Oct-13 14:27 
JokeRe: Catastrophic Failure! Pin
Matt T Heffron18-Oct-13 14:51
professionalMatt T Heffron18-Oct-13 14:51 
GeneralRe: Catastrophic Failure! Pin
PIEBALDconsult18-Oct-13 15:04
professionalPIEBALDconsult18-Oct-13 15:04 
GeneralRe: Catastrophic Failure! Pin
Brisingr Aerowing18-Oct-13 15:25
professionalBrisingr Aerowing18-Oct-13 15:25 
GeneralRe: Catastrophic Failure! Pin
vonb22-Oct-13 2:07
Membervonb22-Oct-13 2:07 
GeneralRe: Catastrophic Failure! Pin
Argonia23-Oct-13 5:49
professionalArgonia23-Oct-13 5:49 
GeneralRe: Catastrophic Failure! Pin
Brisingr Aerowing23-Oct-13 13:55
professionalBrisingr Aerowing23-Oct-13 13:55 

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.