• Best Guest (unregistered)

    frist

  • (nodebb)

    The VB.Net submission is perfectly valid, written in C# it would look like this:

    {
        ...
    }````
    
    Apparantly they have a generic UserSession<T> class somewhere in the codebase, and someone created a derived version without generics.
    
    **Addendum 2016-09-06 08:11:**
    Looks like the Markdown parser here is utterly broken... 
    
    

    public class UserSession : UserSession<UserSession> { ... }

  • (nodebb) in reply to AlexMedia

    Yeah, and in the CRTP as well. The Curiously Recurring Template Pattern, a C++ thing where a class derives from a template class using the derived class as a template parameter.

    https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern

  • Bert (unregistered)

    It's no longer 1950. Please don't shout Lisp.

  • Balu (unregistered)

    Well, actually there's a bit more to SQL Server Reporting Services and the accompanying designer than "If you can use Excel, you can create reports". The fact that you can script the behavior of elements is quite useful and it is more than just VBA - it is actually VB.NET (have you ever tried to display Code128 barcodes on an invoice...?).

    However, this code snippet shows exactly what happens when you let someone who thinks he knows Excel create a SSRS report with the report designer...

  • (nodebb)

    It seems LISP could stand double the amount of nested parentheses.

    https://github.com/syl20bnr/spacemacs/issues/6287

    And for the sake of nitpicking: that's not about LISP itself, but the machine interpreting it.


    In response to AlexMedia:

    do you mean the VB.NET code is valid as VB code, or valid as WTF? (Both are acceptable)

    You can even declare a variable with that name that is different from all those classes:

    Private UserSesson As UserSession

    This reminds me of my first experiences with BASIC, where A, A$, A(), A$() referred to different entities each.


    In one of our product we still have tons of legacy code where an amount of zero means that something isn't available or isn't chosen.

    So what to do if 0.00 € is a valid amount to be calculated with? And Nullable<T> hasn't been invented yet?

    Simple:

    amount = 0.00001; // the rounding on output will take care of those small amounts

    The code in this example is more elegant for it uses a constant for it. I really should suggest to introduce a constant:

    const double zeroAmount = 0.00001;

  • Pussycat (unregistered)

    ZERO = 0.1f

    for when you want to divide by zero without getting an error

  • Ron Fox (google) in reply to Pussycat

    Or in a numerical analysis code when you want to see if there's convergence as in: if (abs(lastIteration - thisIteration) < ZERO) ;-)

  • Angela Anuszewski (google) in reply to Pussycat

    Hah! I like your thinking. The real reason was much more mundane but it isn't as funny if I explain it...

    Addendum 2016-09-06 10:11: OK, I guess I will.

    The function this came from is controlling a device - the number "ZERO" is being compared to is a derivative of the reading from the device. Since there are things like noise, sampling errors, calibration errors, etc. 0.01f is good enough in context to say the device has stopped moving.

    I will just say that this line of code is one from an end product that costs the U.S taxpayers $17 billion. If you knew what the device was and you paid any of that money, you would be weeping right now.

  • Foobar (unregistered) in reply to Ron Fox

    In numerical analysis, you don't use the word ZERO for "close enough", you call it EPSILON.

  • (nodebb) in reply to Foobar

    But EPSILON is Greek, and nobody wants that. And doesn't ZERO sound far more enterprisey?

  • (nodebb) in reply to PWolff

    Well, if we are getting into origins of words, there's a documented and somewhat tortured path from "zero" back to an Arabic word. Take that for what it's worth, which admittedly isn't much.

  • Game Engine developer (unregistered) in reply to Pussycat

    Was about to write thia one myself. Although, 0.01 seems huge for such purposes, even if we are talking 2B floats. Also, I prefer to call it epsilon so you can have fus=ro/(dah+ epsilon);

    This is very common in code where performance matters to the point where you cannot afford branching when you do a divisuon and precision is wibbly-wobbly anyways, like computer games.

  • (nodebb) in reply to Steve_The_Cynic

    Makes sense, since it was the Arabs that introduced the concept of zero, which was unknown to the Greeks and Romans at the time.

  • Carl Witthoft (google) in reply to Foobar

    Very much THIS. Code which is fragile with respect to true "zero" should oughtta be written with either #def EPSILON machine.eps (or equivalent) or with nice clean if x < $SMALL_VALUE then {don't try to calculate y/x or log(x) }

    And yet, some nonvanishingly small number of questions on StackOverflow ask why the user can't get float(x) == float(y) to be TRUE when it should be. Sigh.

  • Carl Witthoft (google) in reply to Bananafish

    Nearly all sources on the InterTubes disagree. It was almost certainly folks on the Indian Continent who got it first. https://en.wikipedia.org/wiki/0_(number)#History

  • Jeremy Hannon (google)

    SSRS can be used as an end-user tool, or as a developer tool with some powerful features, including being able to add your own .DLLs, custom functions, etc. This is an example of how their .Net based expression syntax can be abused though (it is annoying at times).

    The worst problem with this example is that SSRS provides a way to handle this multiple-if-then-else logic in an expression. It gives you a function called Switch that lets you pass "unlimited" pairs of arguments where the first is a Boolean expression, and the second param being the value to return. No need to nest parenthesis, just to make sure you put commas between them.

    Still, doing that in a function is really a WTF in the first place, but these are expressions not functions so everything has to be inline (use a different part if you want to write your own function that can then be called in-line)

  • Jeremy Hannon (google) in reply to Carl Witthoft

    Trust me, referencing Wikipedia as your source material doesn't help much. I have seen several times where something is factually wrong, but keeps being set that way because it can be referenced at a number of "reliable sources".

  • nanis (unregistered) in reply to Carl Witthoft

    While Indians were the first to use zero, the concept was transmitted to Europe via Arab scholars. From the same page you cite:

    The Hindu–Arabic numeral system (base 10) reached Europe in the 11th century, via the Iberian Peninsula through Spanish Muslims, the Moors, together with knowledge of astronomy and instruments like the astrolabe, first imported by Gerbert of Aurillac. For this reason, the numerals came to be known in Europe as "Arabic numerals".

  • thosrtanner (unregistered)

    I've seen several places that suggest the Mesopotamians had the idea of a zero around 3,000BC (which made its way to India and then back to Europe, this taking 4,000 years to make it this far North), and the Mayans developed it around 30BC.

  • Frank (unregistered) in reply to Carl Witthoft

    Even weirder when FP values ARE exactly equal when you don't expect them to: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=781997

  • Norman Diamond (unregistered)

    0.01f is good enough in context to say the device has stopped moving. I will just say that this line of code is one from an end product that costs the U.S taxpayers $17 billion. If you knew what the device was and you paid any of that money, you would be weeping right now.

    A hammer?

  • Mozsafa ebd Pak (unregistered)

    Even if someone doesn't like the word 'epsilon', not one iota will be changed about the fact that ZERO should be equal to 0. https://www.vocabulary.com/dictionary/iota https://en.wiktionary.org/wiki/iota#Noun

  • akozakie (unregistered)

    One thing the professors used to repeat ad nauseam was "Floating point values are never equal, if they are, you probably have a bug, most likely = instead of == somewhere". Good rule of thumb, even if obvious exceptions exist.

  • Pait (unregistered)

    My much senior colleague wrote

    #define NULLP ((void*)0x01)
    

    into his "framework". Intentionally... So you see, there is many uses for non-zero zeros.

  • Angela Anuszewski (google) in reply to Norman Diamond

    I can't tell you what the rest of the function does. But I will tell you that I have been writing software for the government for almost 20 years now, and the mere existence of this function is the biggest WTF I have ever encountered. And this is government work, so that's saying something.

  • (nodebb) in reply to Angela Anuszewski

    I can't tell you what the rest of the function does.

    So... it is either involved in avionics or the email server for the Secretary of State.

  • Foo AKA Fooo (unregistered) in reply to Mozsafa ebd Pak

    I agree from alpha to omega. There really is a delta between zero and epsilon, even if it's smaller than a mu.

  • (nodebb) in reply to Carl Witthoft

    Seems Nanis found a citing (same one you did?), but I didn't need one. It was the Arabs who introduced the concept of zero to Europeans -- which includes the Romans and Greeks in addition to the Spaniards -- and that none of these cultures had a representation of zero in their numbering systems until it was brought to them by the Moors. Pay attention in history class and you too can be a Moorish Wizard!

    In Roman numeral math prior to the 12th century AD, one could represent "10 - 5" as "X - V" with a result of "V", but "X - X" was just about as impossible then as division by zero is for us now. The answer cannot be represented -- there was no zero. Curiously, it is for the same reason division by zero is not possible: The exact number of times the value zero can be subtracted from any value cannot be represented.

  • I'm not a robot (unregistered) in reply to Bananafish
    In Roman numeral math prior to the 12th century AD, one could represent "10 - 5" as "X - V" with a result of "V", but "X - X" was just about as impossible then as division by zero is for us now. The answer cannot be represented -- there was no zero. Curiously, it is for the same reason division by zero is not possible: The exact number of times the value zero can be subtracted from any value cannot be represented.

    No, division by zero is not possible because multiplication by zero isn't bijective, and therefore its inverse doesn't exist. If it was just about "representation" then someone would invent a symbol for it (and indeed people have done so, but the resulting system isn't consistent with the conventional laws of arithmetic).

  • I not a robot either (unregistered) in reply to Bananafish

    Roman numerals were used for writing numbers in text. They were not used for calculation. In trigonometric or astronomical tables were high precision fractions were needed the ancients used various variations of positional notation, usually with Greek numerals, and they absolutely used symbols for zero; see for example https://en.wikipedia.org/wiki/Ptolemy%27s_table_of_chords and https://en.wikipedia.org/wiki/Greek_numerals.

  • Voxera (unregistered)

    Someone's been spying on my code !!

    That die ASP VB function looks exactly like my die(s) function, it even uses s for the message ;)

    (Mine is till in active use in some old code still lingering within one of our applications, going for it's 17'th year soon)

  • (nodebb) in reply to I not a robot either

    Yes, they did. AFTER they learned about zero from the Arabs.

  • the cow (not the robot) (unregistered) in reply to I'm not a robot

    then someone would invent a symbol for it (and indeed people have done so, but the resulting system isn't consistent with the conventional laws of arithmetic).

    This? https://en.wikipedia.org/wiki/Homogeneous_coordinates

Leave a comment on “What You Don't See”

Log In or post as a guest

Replying to comment #467925:

« Return to Article