Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Blast you Vilmos and Your Clever Cleverness!

Blast you Vilmos and Your Clever Cleverness!

Scheduled Pinned Locked Moved The Weird and The Wonderful
toolsquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nagy Vilmos
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • N Nagy Vilmos

      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

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I always try to keep these wise words in mind: "Just when you think that you've got it... it blows up in your face." -- The Leslie Spit Treeo http://www.youtube.com/watch?v=BKb_cPzpNNQ[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups