Path: news.daimi.aau.dk!olevi From: olevi@daimi.aau.dk (Ole Villumsen) Newsgroups: comp.object,comp.lang.eiffel,comp.lang.sather,comp.lang.beta,comp.lang.modula3 Subject: Beta syntax (was Re: Cows, Hogs & Farms) Followup-To: comp.lang.beta Date: 9 Jan 1995 15:25:59 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 101 Message-ID: <3erki7$a8@belfort.daimi.aau.dk> References: <3eih36$94g@network.ucsd.edu> <1995Jan6.164948.4782@schbbs.mot.com> <1995Jan9.005627@hobbit> NNTP-Posting-Host: angers.daimi.aau.dk Xref: news.daimi.aau.dk comp.object:23574 comp.lang.eiffel:7132 comp.lang.sather:1399 comp.lang.beta:207 comp.lang.modula3:3310 In Danish schools, we learn that multiplication is denoted by a dot (or nothing at all: xy means x times y), and a colon : is used for division. When I started learning programming, I learned that * meant multiplication, and / was used for division. It's no problem: I got accustomed to * and / very quickly and never gave it a second's thought. It's the same with Beta: A few things that are used often have a short notation in Beta that every programmer uses without thinking about it; but they (and especially the sum of them) are apt to confuse people who don't know Beta. For instance (from David L. Shang 's posting): >> or BETA's form: >> >> MONOCULTUREFARM >> (# ANIMALT :< HERBIVORE >> attr livestock : @list (# eleT::ANIMALT #); >> attr foodstock : @list (# eleT::ANIMALT.FOODT #); >> #) The "attr" in the above should be deleted. The "@" later in the same lines do the job; which is very convenient once you know it. That's Beta. I'll return to "@" below. (Also, there should be a colon : after MONOCULTUREFARM - it wasn't important, as the original posting didn't discuss syntax details; but we do now.) Mark S. Hathaway asks: >It's not especially readable, is it? Most people dislike Beta's syntax at first. As a more experienced user I'd say, it's very straightforward to read once you've learned it. But beautiful - it's not. >Is it really ":<" rather than Cluster's "<:"? Very funny contrarianism! >Since "ANIMALT :< HERBIVORE" is inside the "(#" & "#)" enclosure I wouldn't >guess you could create a MONOCULTUREFARM(COW). In Beta, you create a MONOCULTUREFARM(# animalT::cow #) I suppose it's the same, only with a different syntax. Just like you create a list (# eleT::ANIMALT #) instead of a list(animalT). ("List" alone would be a list that could contain any type of objects.) Not knowing Cluster, I don't think Beta's ":<" and Cluster's "<:" have exactly the same meaning. Maybe it's a pure coincidence that the two languages include symbols made up of the same 2 characters. Beta uses x : ... for an ordinary (static) declaration x :< ... for a virtual declaration x ::< ... for a further binding (extension) of a virtual x :: ... for a final binding (after which x is no longer virtual) It's easy and consistent, isn't it? >Since there's no "class" in front of "MONOCULTUREFARM" I'd guess that >everything in BETA is a class or pattern or somethin', huh? So, by >having only one "form" it can be understood what this is. ... Again, you have to know the language - but you'll learn very quickly, since these are the details the Beta programmer uses every day and soon stops thinking about: x: (# ... #); (* declares a pattern (e.g. a class) *) x: @ ... ; (* declares a static instance (object) *) x: ^ ... ; (* declares a dynamic reference to an instance *) > ... Is there >any special notation to differentiate a main program from these others? The main program is preceeded by "--- program: descriptor ---" (which is strictly speaking part of the fragment language, not part of Beta itself). >Yes, the language should provide a way to express something. That's why >I cringe when I see syntax like BETA's. :-) You won't find a programming langauge with greater expressive power than Beta :-) :-) >Since it's not like a procedure within a module the parameters of >MonocultureFarm which are of type/class plant and herbivore aren't >"import"ed first. That's a little awkward, but these other languages >(BETA, Cluster, Sather) don't seem to need the "import". Is it no >longer regarded as necessary? If plant and herbivore are defined in different files (fragment groups), you should do an "include" of those files. Again, this is done using the fragment language. If you have other Beta questions, please ask. You can also read more in the Beta FAQ file. I have set follow-ups to comp.lang.beta. Ole -- Ole Villumsen, Computer Science Department, Aarhus University, Denmark A European Union is a self contradiction. Either the European will kill the union, or the union will kill the European.