Conversation

eli, shadow domme

code snippet
Show content
bool IsApproxEqual(float a, float b, float epsilon = Mathf.Epsilon) // Default parameter value for 'epsilon' must be a compile-time constant

unity. why. why is your epsilon value a readonly static.

1
0
3
re: code snippet
Show content

@rowan I’m out here wondering what the logic code is all about. What breaks if it isn’t a constant? Either this is extremely hyper optimized code along the likes of Quake3 fast inverse square root, or its cursed neodog_think_googly

1
0
2
re: code snippet
Show content

@ilobmirt hehehe! 💜 in c#, default parameters need to be a statically analyzable constant value; i assume this is probably to help ease static analysis and parsing efforts of the compiler when it comes to type checking and dealing with potential side effects from code

in javascript and python, you can do really cursed amazing things with default parameters

function sideEffect(value) {
  console.log(value)
}

function someFunc(value, optionalValue = sideEffect(value)) {}

someFunc(1) // console prints '1'
1
0
1
re: code snippet
Show content

@rowan @ilobmirt in Python this is even more cursed because sideEffect(value) only gets evaluated once which is a Terrible Fucking Behavior and lets you do shit like this:

def internal_append(value, list_ = []):
    list_.append(value)
    return list_

internal_append(1) # -> [1]
internal_append(2) # -> [1, 2]
internal_append(3) # -> [1, 2, 3]

I actually think that JS’s behavior is really nice though

0
0
1