Path: news.cs.au.dk!not-for-mail From: Flemming Gram Christensen Newsgroups: comp.lang.beta Subject: Re: Tha Master of Stupid Questions is back ÆÆÆÆH! Date: 15 Jun 2000 15:45:45 +0200 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 91 Message-ID: References: <393FA45B.FD97119D@skynet.be> NNTP-Posting-Host: odin.mjolner.dk X-Trace: xinwen.cs.au.dk 961076749 126239 255.255.255.255 (15 Jun 2000 13:45:49 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 15 Jun 2000 13:45:49 GMT X-Newsreader: Gnus v5.7/Emacs 20.4 Xref: news.cs.au.dk comp.lang.beta:12406 Atle writes: Subject: Re: Tha Master of Stupid Questions is back ÆÆÆÆH! Newsgroups: comp.lang.beta References: <393FA45B.FD97119D@skynet.be> Atle writes: > This time, it is about language syntax. > I hope i don't tough on sensitive issues with my questions, but here it is: > > About the operators @,^, []. > > Why are there two operators basically denoting the same thing (reference)? > As you know @ and ^ are used when declaring attributes (references ). Lets throw in some examples, say: q:(# ... #); p: (* a normal pattern *) (# s:@q; t:^q; #); p.s is a static reference. p.s refers a fixed object of exact type q. This is used eg. to model partobjects. p.t is a dynamic reference. p.t can point to any object qualified by at least q or be none (point to no object). p.s allways referes to the same object, whereas p.t can point to difference object during program execution. > When declaring a reference, ^ is used, and when accessing it, [] is > used - why? > given that MyP is a reference to a p object we can use the attributes like: a) MyP.s or b) MyP.s[] or c) MyP.t or d) MyP.t[] which means: a: execute MyP.q's dopart. b: denotes a reference _to_the_ object MyP.s. This can be used in assignments: MyP.s[]->MyQ[]; Now MyQ refers (or points) to the MyP.s object. (We now have two references). c: execute the dopart of the object pointed to by MyP.t or die with "reference is none". d: similar to b. Note that we get a reference to the object MyP.t is pointing to, not a reference to MyP.t. There is no such thing as pointers to pointers. The choice of [] is only syntax, it could be one of !@#$%^ etc. It is only a matter of syntax, but we need a way to distinguish a) from b). > What would be the consequence of using ^ in accesses, or [] in declarations? > I am only 1/3 way through the BetaBook, but I don't see any easy explanation for this? > > Of course, the same applies in a different way to @ and (eh, well, what?) > If ^ must be used to denote reference, and @ is used to denote value, when declaring object, why isn't the same sort of rules > applied to access? One could write example a as MyP.s@ and b as MyP.s^ ? I would not like it. >To me, Beta seems to be about consistency and minimalism, why this extra grammar? > Is there some history here? I do not know. Some of the syntax was chosen deliberately to not look like C. > > Thanks, Atle > Regards -- /Flemming Gram Christensen