What's the difference between void display and void render?

I'm returning to processing after having been away for a time. I'm forgetting some details and I'm probably not aware of recent changes. Thanks in advance.

Answers

  • Have you consulted the reference? https://www.processing.org/reference/

    Where are you seeing void display or void render?

  • I'm going through the Nature of Code book. The text (which understandably may not be up to date) has: void display ().

    However I downloaded their up to date github code which uses void render().

    I can not find any documentation on either.

  • Answer ✓
    • Neither display() nor render() belong to Processing framework's API!
    • They're just made-up method names for some class.
    • Avoid using keyword void when referring to method/function names. It's pointless! 8-|
  • I'm honestly not really sure what you're talking about.

    A basic Processing sketch uses a draw() function, not render() or display(). Those might be methods used in a class somewhere, but it's not like Processing has changed its basic functions or anything.

  • Oh, okay. My misunderstanding. They are just method names. The code in question is in regards to a class. I mistakenly thought it was a part of the API. Thanks for the clarification. Also, Shiffman's code uses "void" for these method names. I'm not sure what his reasoning is behind that.

  • Also, Shiffman's code uses "void" for these method names.

    What were you expecting?

  • Also, Shiffman's code uses "void" for these method names.

    Java syntax demands that a function/method specify which datatype it returns.
    Keyword void simply means that it returns nothing:
    https://processing.org/reference/void.html

  • My CS knowledge is spotty and inconsistent. Can anyone explain to me why void should or should not be used in a method name? It seems like there's a difference of opinion or am I misunderstanding this?

  • I just meant that calling a method void setup() is cumbersome. Just say the name w/ parens: setup(). ;)

  • Functions have a return type, in the case of void it means that the functions returns nothing. If you had a function that returns say an integer then you can use that integer:

    void setup() {
      size(100, 100);
    
      // Print the return value
      println(foo());
    
      // Assign the return value to a variable
      int var = bar();
      println(var);
    
      // Don't do this, it would cause an error
      //println(baz());
    
      exit();
    }
    
    int foo() {
      return 1;
    }
    
    int bar() {
      return 2;
    }
    
    void baz() {
    }
    
  • Also if it was not clear, display and render are arbitrary names for functions (the name chosen is probably just based on what the function does). The void before the function name is the return type

  • That makes sense, thanks.

Sign In or Register to comment.