Talk:Glass

From Esolang
Jump to navigation Jump to search

What's with the huge headers? --Ihope127 00:04, 22 Oct 2005 (GMT)

I LIKE WRITING BIG, IT MAKES ME FEEL COOL --GregorR 00:49, 22 Oct 2005 (GMT)

I finally started (a bit belatedly) actually experimenting with Glass, and I immediately found a surprise.

In the cat.glass example provided with the interpreter, I expected to be able to replace (_t)(ln). by (ln)* since the function is within the same class as (ln) is defined in, but it doesn't work.

However, if I first insert (ln)(_t)(ln).= then it works. However, inserting (l)(_t)(ln).= and then using (_t)(l). does not work either.

From this I guess that object and class environments are entirely separate, even though they both use small letters, and that * looks up an item in the current object's environment but . looks it up in an object's class. I will try to modify the ? description accordingly.

Also, since there is no assignment corresponding to . like = corresponds to *, I take it that class environments are always immutable and only contain the original functions. --Ørjan 20:42, 12 Jun 2006 (UTC)


There must be another subtlety. I tested the following definition of a simple initializable counter:

{C
 [(c__) x 1 = ,]
 [(inc) x x * <1> (_a)A! (_a)a.? =]
 [(rx) x *]
 [x x *]
}

The constructor (c__) initializes the object from the stack, (inc) increments it, (rx) retrieves its value. Everything works as expected (also with multiple instances) as long as the x function is not called. But if it is, the program crashes. If class and object environments were entirely separate, x function should work like (rx). If they were intertwined somehow, then just defining the x function with the same name as the instance variable might ruin independence of instances, but it doesn't. Hm. I've got another test to do...

OK, the following clarifies things (maybe):

{F
 [x <1>]
 [d x (_t)$ (_t)x. =]
 [(rx) x * ?]
}

Using the x function works fine until d is run, assigning to x the "same" function. After this, another attempt at (_t)x. will crash, even without the ?. So it seems like using . to retrieve a class function which is also an object variable crashes.

On the other hand, after d is run, (rx) can be run and the result will be the same as from the original function x, because it was saved in the object variable x, which (rx) uses. Confusing enough yet? :-)

My summary guess is: Class and object environments are entirely separate, except that if the class and the object shares a variable name, trying to get to the class one will crash. --Ørjan 22:12, 12 Jun 2006 (UTC)

Glass is the most popular on the 99 Bottles site!

Check it! —The preceding unsigned comment was added by IanO (talkcontribs) 18:44, 8 Aug 2006 (UTC).

Not any more. It's easy for any new entry to be first temporarily, as the author only needs to recruit a few friends to give it a five-star rating. They should probably take an approach like that used on the Internet Movie Database Top 250:
The formula for calculating the Top Rated 250 Titles gives a true Bayesian estimate:

weighted rating (WR) = (v ÷ (v+m)) × R + (m ÷ (v+m)) × C

 where:
  R = average for the movie (mean) = (Rating)
  v = number of votes for the movie = (votes)
  m = minimum votes required to be listed in the Top 250 (currently 1300)
  C = the mean vote across the whole report (currently 6.8)

for the Top 250, only votes from regular voters are considered.
--Safalra 13:28, 9 Aug 2006 (UTC)

Inheritance

How can this really be considered truly OO until classes can inherit functions from other classes? Someone should create a derivative with said functionality. --Quintopia 20:07, 6 March 2009 (UTC)

Comments

"'comment' isn't parsed at all, it's a comment (non-nestable)"

Of course it isnt nestable; the start and end chars is the same! --87.59.204.105 12:14, 6 February 2010 (UTC)