Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'essentially': 0.04; 'root': 0.04; 'cpython': 0.05; 'indicating': 0.05; '(b)': 0.07; 'classes.': 0.07; '(string,': 0.09; 'instances.': 0.09; 'internally': 0.09; 'python': 0.11; 'example:': 0.11; 'language,': 0.11; 'index': 0.13; 'subject:python': 0.14; 'represents': 0.15; 'things.': 0.15; '(eg.': 0.16; '4:59': 0.16; 'confusion': 0.16; 'distinction': 0.16; 'integers,': 0.16; 'stored.': 0.16; 'subject:class': 0.16; 'subject:object': 0.16; 'subject:type': 0.16; 'user-defined': 0.16; 'wrote:': 0.16; 'string': 0.17; 'integer': 0.18; 'mechanism': 0.18; 'pointer': 0.18; 'examples': 0.18; 'language': 0.19; '(or': 0.21; 'class,': 0.22; 'help.': 0.23; '2015': 0.23; 'designated': 0.23; "haven't": 0.24; 'header:In-Reply-To:1': 0.24; '(this': 0.24; 'mon,': 0.24; 'developing': 0.25; 'define': 0.27; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; "i'm": 0.29; 'behaviour': 0.29; 'itself,': 0.29; 'types.': 0.29; 'array': 0.29; 'objects': 0.29; '(which': 0.29; 'classes': 0.30; 'connection': 0.30; 'lines': 0.30; 'work.': 0.30; 'certainly': 0.31; 'print': 0.31; 'code': 0.31; 'similar': 0.32; 'skip:[ 10': 0.32; 'language.': 0.32; 'class': 0.33; 'instances': 0.33; 'int': 0.33; 'received:google.com': 0.34; 'useful': 0.35; 'could': 0.35; 'to:addr:python-list': 0.35; 'done': 0.35; 'along': 0.35; 'something': 0.35; 'really': 0.35; 'list': 0.35; 'but': 0.36; 'there': 0.36; '(and': 0.36; 'others.': 0.36; 'quite': 0.37; 'display': 0.37; 'subject:: ': 0.37; 'rather': 0.38; 'brief': 0.38; 'pm,': 0.39; 'things': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'data': 0.40; 'some': 0.40; 'above,': 0.63; 'details': 0.63; 'within': 0.64; 'different': 0.64; 'between': 0.65; '20,': 0.66; 'picked': 0.66; 'direct': 0.70; 'sounds': 0.72; "'object'": 0.84; 'everything,': 0.84; 'perspective.': 0.84; 'to:name:python': 0.84; 'tricky': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=r0IN7o7M9doMkJOolHByj4gw3rmnr2s5jFegWbLZQ0w=; b=eAUcknG6l+0Kc2o/UWTV8Gz4xblPEnnY0a8cNj4ESrK5Z5XwXDmNGAlg5YFo9dDlWe hcwR9gTaYrOC/esMKELx22GeZprgQhV/DlHFKcyhWiWGsCIUv+RGxlhVzRJqocp9z+uk okKXKOpJmZDEhCzUuz0JW48bBb4qLDH+dnmYI6raJizbdKIdByqf3LHemlXFZ6PbeEWN vNKXeDmGVGP/xLPNnFw/nEj6JCIBNAx0YSFjwGF2gFCjD3Gcfe480ffucUYuJAR3fvHL GhTI4NTU6RIVOhvc9XS1oNQaeFfatAYV3W+UnhLi3AfzlGWbQzBV136TMBC160OJJxRV 4mng== X-Received: by 10.50.25.162 with SMTP id d2mr10484514igg.11.1433257830175; Tue, 02 Jun 2015 08:10:30 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <3t5bx.755107$dj1.564752@fx03.am4> References: <14976c1b-a620-426f-b529-41a3c04e9c1a@googlegroups.com> <7f287dcf-8d52-4ab8-9768-88d1f75da269@googlegroups.com> <3t5bx.755107$dj1.564752@fx03.am4> From: Ian Kelly Date: Tue, 2 Jun 2015 09:09:49 -0600 Subject: Re: Everything is an object in python - object class and type class To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433257833 news.xs4all.nl 2964 [2001:888:2000:d::a6]:44227 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91847 On Mon, Jun 1, 2015 at 4:59 PM, BartC wrote: > I'm developing a new language along the lines of Python, perhaps a brief > description of how things are done there might help. Or just give a > different perspective. > > Objects in this language are tagged: there's a code attached to each > indicating what kind of data is stored. These codes are integers, or > enumerations, for example: > > Int = 1 > String = 2 > List = 3 > Class = 4 > > And the following are examples of object instances with their tags: > > a is (Int, 42) > b is (String, "ABCXYZ") > c is (List, [10,20,30,40]) > d is (Class, 2 or ) > > The last one might be tricky to grasp: it's really just a number, but one > that represents a class or type (or tag). If printed, it could display > rather than just 2. (And when used to do something with the class, > the 2 might be an index into a set of tables.) > > d is not /the/ class itself, but just a reference to it (this is pseudo-code > not Python): > > print (b) => ABCXYZ > print (typeof(b)) => String <2> > > print (d) => String <2> > print (typeof(d)) => Class <4> > print (typeof(typeof(d))) => Class <4> > > In my own language, the connection between class and type is hazy (I've only > just added classes so it needs to be hazy until I understand them more). > > 'Type' includes everything, including all the built-in types such as the > tags above, but also user-defined classes. In fact classes are the mechanism > used to define new types. But with both designated by an integer within the > same band (eg. built-int types 1 to 20, user-defined classes 21 and up), it > is easier not to have a strong distinction ... at the moment. > > I haven't a root class yet that is the base of all the others. I don't think > it's necessary internally to make things work. But it might be a useful > concept in the language. Calling it 'object' however might give rise to > confusion as 'object' is informally used to refer to instances. (I've never > used OO but have picked up some of the jargon!) > > (This is almost certainly not how Python does things. Although the Python > language doesn't go into details as to its implementation provided the > behaviour is correct.) It sounds quite similar to me. In CPython at least, every object has a direct pointer to its type rather than an array index (which is essentially just an offset from a pointer).