473,779 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[2.3] object does not appear to be a reserved word

Is it potentially dangerous to use the variable 'object' in code?

Thanks,
Daniel Klein
Jul 18 '05 #1
4 1297

"Daniel Klein" <da*****@aracne t.com> wrote in message
news:v8******** *************** *********@4ax.c om...
Is it potentially dangerous to use the variable 'object' in code?
"object" is, I believe, a built-in type in the builtins namespace.
As such, you can shadow it so it's inacessable. However,
the only place were that could cause problems is if you
use it as an identifier at the module level. I think.

John Roth
Thanks,
Daniel Klein

Jul 18 '05 #2

"Daniel Klein" <da*****@aracne t.com> wrote in message
news:v8******** *************** *********@4ax.c om...
Is it potentially dangerous to use the variable 'object' in code?


Yes, it is potentially dangerous to use any of the names in the
builtin module. It is disrecommended for posted/public code without
good reason (intentional override).

TJR
Jul 18 '05 #3
John Roth wrote:
"Daniel Klein" <da*****@aracne t.com> wrote in message
news:v8******* *************** **********@4ax. com...

Is it potentially dangerous to use the variable 'object' in code?


"object" is, I believe, a built-in type in the builtins namespace.
As such, you can shadow it so it's inacessable. However,
the only place were that could cause problems is if you
use it as an identifier at the module level. I think.

Another place: errors in (copied) code which get silently ignored
because of the presence of the "object" type.

For instance, if you cut-and-past a few lines of (older, particularly
pre-2.2) code which uses the variable "object" into a new situation
which uses "item" (or whatever), the older code will often seem to be
functioning properly because it uses the type "object" as an instance,
instead of raising a NameError. Tends to result in subtle bugs, but not
likely enough to warrant breaking all the old code that used "object" as
an identifier by making it a keyword.

To answer the original question, yes, it's somewhat dangerous to use
"object" as an identifier in code. It's approximately equally dangerous
to use "str", "list", or "tuple" as an identifier. It's just that the
temptation to use "object" is greater when you're doing a lot of
polymorphic programming, and you'll find older code (pre 2.2) using it
without any concern whatsoever (because there was no object type back
then to cause a problem).

Each new built-in causes the same problem, it's just that "object" is so
fundamental an idea (both as a built-in and an identifer) that it's
probably the most likely source of such low-level conflicts going
forward. (e.g. enumerate, or zip are used in code once in a while, but
compared to "object" are fairly uncommon choices for an identifier).

Enjoy,
Mike

_______________ _______________ _________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/


Jul 18 '05 #4
Thanks John., that's what I suspected.

This particular module uses the variable 'object' as an argument to
several methods and functions. I'll probably change it anyway, but I
was just curious as to why it seemed to run ok.

Thanks again for the confirmation.

Dan

On Sat, 6 Sep 2003 15:47:07 -0400, "John Roth"
<ne********@jhr othjr.com> wrote:

"Daniel Klein" <da*****@aracne t.com> wrote in message
news:v8******* *************** **********@4ax. com...
Is it potentially dangerous to use the variable 'object' in code?


"object" is, I believe, a built-in type in the builtins namespace.
As such, you can shadow it so it's inacessable. However,
the only place were that could cause problems is if you
use it as an identifier at the module level. I think.

John Roth

Thanks,
Daniel Klein


Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6391
by: Joshua Beall | last post by:
Hi All, What does the "const" reserved word in PHP4 do? I know it is a reserved word in PHP4, but the only references I can find to it are for PHP5. Here's what I want to do: Rather than using define(), I'd like to declare a variable as a constant. This way, I can use it in strings. Specifically, in heredoc strings - constants don't get interpreted in between <<<EOT and EOT;
106
5610
by: A | last post by:
Hi, I have always been taught to use an inialization list for initialising data members of a class. I realize that initialsizing primitives and pointers use an inialization list is exactly the same as an assignment, but for class types it has a different effect - it calls the copy constructor. My question is when to not use an initalisation list for initialising data members of a class?
2
12384
by: Matthew Cascio | last post by:
My understanding is that using reserved words as column names is allowable as long as they are quoted. I am trying to create a table dynamically with columns defined by the first row of a text file I import. Unfortunately, I have no control over the column names and the data provider has chosen to use the word "USE" as a column name. "USE" is a reserved word. To handle this, I tried quoting the word during the CREATE TABLE statement,...
7
2239
by: Michael Hill | last post by:
If I have: <a href="javascript:myfunct('cool_links')" id="cool_links"> and I refer to it as: function myfunct(mylink) { document.getElementById }
14
7444
by: Matt | last post by:
I want to know if "int" is a primitive type, or an object? For example, the following two approaches yield the same result. > int t1 = int.Parse(TextBox2.Text); //method 1 > int t2 = System.Int32.Parse(TextBox2.Text); //method 2 And people said "int" is a C# alias for "System.Int32". If this is the case, can we say "int" is an object??
6
2188
by: gizmo | last post by:
I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word). My problem is that I need to kill each instance individually, but this does not appear possible using the Process object. When I run the example below the process object "p" can be viewed using Quick Watch however process object p2 is displayed as undefined, with the added affect of not...
28
2129
by: ensemble | last post by:
I'm trying to utilized a more object-oriented approach to managing window events in javascript. Thus, I am creating a "controller" object to handle events and interact with the server. However, I apparently don't fully understand what "this" refers to. In the code below I was expecting that when the button was clicked (handleDeleteButtonClicked function) that "this" would be pointing at a ViewController object. Instead it was the Button...
6
14119
by: Christoph Boget | last post by:
If I had an array like so: var bob = ; I can find out the size of the array by doing bob.length; Is there a comparable way to get the size of an object? So if I did:
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.