# Object name as a function

Clueid shared this question 3 years ago

Hello,

I noticed that when I rename an object to a pre-defined function name I get a weird output. Why is that?

Example: Name a point "Point", then type "D = Point(xAxis)" and you'll get an error.

Example: Name a point "Line", then type in the input "Line(P, Q)" you'll get a weird number. It has got little sense, but if you explicitly want to know it, just give it a try, it's a simple deduction by entering clear values. You'll quickly notice some work others don't, but in general you can say that the name is used as a value. So let's start with objects given names as the thype of the object itself.

Point(Point) = x² + y².

Point (Segment) is a dilatiation with the lenght of the Segment as dilatation factor. Here the coordinates are multiplicated with a factor that equals the lenght of the segment.

Line(Line) doesn't work since the length of a Line is not defined. You can't multiply it by an equation of a line.

Polygon(Polygon) gives the square of the Area, because in it the two values are multiplicated.

So you can work with them as the name is used as the value of it (coordinates of a point, lenght of a segment area of polygon etc). But you can't use it in a command Point(xAxis) since in this expression a value has no sence.

In brief: if possible using names works as using the value of it in an expression and it depends on the exprssion if using a value has got sense or not. 4*(xAxis) doesn't have any sense, but 4 * 4 (being e.g. the length of a Segment) does and gives 16 as result. Distance((4, 2), 5) has no sense so Distance(Point, Segment) with used names will produce an error etc.

That's all... 2

Isn't it normal that you can't use the same, let's say 'word' for two different kind of things, a command and an already used name for an object? But if you explicitly want to use those kind of terms, used in commands as Point( ) or Line() you could use the same word without capital letters. There's no problem with a name and a definition as e.g. point = Point(xAxis) etcetera.

chris 1

Thank you Chris for your answer. I'd like to know what do these functions actually do. What is the meaning of the output of these functions..?

Thank you  1

I'd like to know what is the output of using the name of an object as a function... 2

It has got little sense, but if you explicitly want to know it, just give it a try, it's a simple deduction by entering clear values. You'll quickly notice some work others don't, but in general you can say that the name is used as a value. So let's start with objects given names as the thype of the object itself.

Point(Point) = x² + y².

Point (Segment) is a dilatiation with the lenght of the Segment as dilatation factor. Here the coordinates are multiplicated with a factor that equals the lenght of the segment.

Line(Line) doesn't work since the length of a Line is not defined. You can't multiply it by an equation of a line.

Polygon(Polygon) gives the square of the Area, because in it the two values are multiplicated.

So you can work with them as the name is used as the value of it (coordinates of a point, lenght of a segment area of polygon etc). But you can't use it in a command Point(xAxis) since in this expression a value has no sence.

In brief: if possible using names works as using the value of it in an expression and it depends on the exprssion if using a value has got sense or not. 4*(xAxis) doesn't have any sense, but 4 * 4 (being e.g. the length of a Segment) does and gives 16 as result. Distance((4, 2), 5) has no sense so Distance(Point, Segment) with used names will produce an error etc.

That's all... 1

is there any documentation for this? 1

I don't think there is. My advice is to follow this hierarchy:

1. Does it have a sense tho apply the name of a define object that appears in a command as the object itself, then the command wil be executed like this.

2 If not 1, does it have a sense to apply the value of this object in the command, then this will be the way it works.

3 If 1 nor 2 works you will get an error 1

Here's a bit of a background of why I asked this question:

It may not make sense in the general case, but it does if you want to make a tool as a shortcut of a command. (e.g: Segment(A, B) is s(A, B)) 