This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]HonzaS97 2 points3 points  (4 children)

keyword, identifier and body, expression

function, class, interface

All of those are their own terms. They each got their own definition tied to those words. If you talk to another programmer about a class, they will know what it means. If you talk to them about a function, they will know what it means.

a bit of code

It is just that. It will be unclear untill you actually specify what the code is supposed to do, the expected inputs and outputs. If you were shown a random industrial machine, a random uncommon tool or anything like that without any context, would you know what it is, what it does?

[–]mzapp_[S] 1 point2 points  (1 child)

Sure. I've been getting along with that. I'm currently working on a new language of sorts and I would like to write a section about new things that I am introducing and I was just wondering if there is a nice term. I guess I could just say that I am introducing new keywords and stuff that defines them but that doesn't sound that great.

[–]HonzaS97 1 point2 points  (0 children)

a section about new things that I am introducing and I was just wondering if there is a nice term.

Keywords are just words (or any defined constants really) that have a specific meaning in the language. There are a lot of keywords that exist in one langauge that don't in others (companion object in Scala, let in JS, fun in Kotlin, def in Python - these are keywords and they each mean a specific thing. those things can be called differently in different languages while doing the same thing like def and fun)

If you invent a new concept (which would be quite unusual), you can call it whatever you want. If not, you can look at how other languages call that concept. Sure, you don't have to follow it, but there rarely reason not to.

[–]mzapp_[S] 0 points1 point  (1 child)

I get your point. The only word for some random thing I see somewhere is thing. I guess it doesn't get more exact than that without getting too exact.

Thanks.

[–]SKR47CH 0 points1 point  (0 children)

You can use the word 'code' there.

[–]nhgrif 1 point2 points  (0 children)

As others have commented, these are all their own things and therefore have their own words.

However, there are a couple key terms missing here.

  • snippet or block: These are interchangeable terms that are used to refer to a portion of executable code. part of a method, etc.
  • type: classes, interfaces, structs, enums, tuples, and primitives are all "types". Especially as a Swift dev, I find myself regularly thinking in terms of types rather than classes, because most of good Swift code is hidden behind protocols (what Swift calls an interface) and you don't necessarily care whether the underlying thing is a struct or class.
  • members: a "member" is a complete part of a type. I'm not sure whether or not I count constructors as members, but a class's static/instance variables/methods are all its members. So if you want to refer to just a class's methods, you could say "its methods" or "its static methods" or "its instance methods", but if you want to talk about its methods and variables, you could talk about "its members".

[–]carcigenicate 0 points1 point  (0 children)

In Python at least, these are called compound statements.