Skip to main content

Is it fair to call a block name an identifier?

Comments

5 comments

  • Micah M
    Beacon of Knowledge

    You will hear lots of different opinions on what to call "identifiers". Different programming languages use different words and in some languages similar sounding words mean subtly different things. In Python, a value you pass into a function (both 10 and "parrot") are usually called arguments or parameters. You will also hear them referred to by their data types: the 10 is an int (integer) and "parrot" is a str (string).

    In Python, strings will have quotation marks around them - single or double quotes are both fine. The quotes are used to differentiate strings from variables. Variables in Python can hold content of any data type. There are a number of good resources online for definitions and explanations of all the different parts of a function and data types. I've linked to w3schools for these topics, but there are a number of other guides online as well.

    1
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Thanks. But isn't it true, though, that any string isn't allowed here, and that only mob names are allowed? In some cases (in other commands), FORWARD, etc are allowed, but in no sense could I say summon "blueparrot" or something. It has to be the correct mob name. So how can I accurately describe this? Since there are many parameters that go in functions, and I want to describe the ones that go here, can I say that the identifiers which are mobs go there?  *sigh* And block names are another whole kind of crazy. =D

    That said, it is utterly amazing to me how many comp sci terms are fuzzy. I guess it is the consequence of it being a new science. But still. Fuzzy.

    1
  • Micah M
    Beacon of Knowledge

    Great question! Python is particularly lax on what you can pass into a function as an argument. The code inside the function has to make sure that the values passed in are correct (both checking data type and allowed values within the datatype). This applies to the other (non-string) parameters too, for example try passing 5.5 as the number.

    In the case of the summon command, you are correct that our code is validating that the string parameters have specific values within them (forward, parrot, block_name, etc.) and will return an error if they aren't. To be semantically correct with a room of CS majors in college, I'd say "the parameter needs to be a string that is a valid [mob, block, etc.] in Minecraft". To a room of younger students, I'd say "look at the name of the [block, mob, etc] in Minecraft and use the same name with quotes around it when you use it in the [summon] function".

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    OKay, this helps. So, in fact, the function just accepts a string. Then a secondary error check looks for a valid block or mob name and dumps an error message if you didn't meet the second error check.

    So it isn't really looking for a specific object or class or anything at the function level. Okay, so I will skip the identifier question, since it seems moot. Thanks. I like to know these things so I don't feel like I am leading people in the wrong direction. =D Appreciated.

    1
  • Micah M
    Beacon of Knowledge

    That's a great summary, you've got it! 

    1

Please sign in to leave a comment.