nXIII wrote:
Code:
var myABC = new (myCar.abc)();
It's not the notation that's confusing me, with or without 'new,' but the semantics. Abc appears to be defined as a method of car. To have an abc that's not part of a car is like the Cheshire cat's smile, regardless of notation! If you're going to want to instantiate abc independently, then it should be defined outside of car, and the car definition should instantiate or subclass it.
What am I missing? Tell me in English, not code.
Thanks.
Offline
bharvey wrote:
fullmoon wrote:
Are you referring to the section where they talk about cat.prototype?
Yes.
PS It's all your fault that I'm not getting any real work done this week!
Well, to be honest, I've never really thought about what the prototype object means in any philosophical way. I don't think it creates a distinction between classes and instances, though, check out the Wikipedia page on prototype OOP for another JS example that uses the __proto__ object instead of constructor.prototype (like the last one). Here's an interesting discussion on the difference between the two.
And yes, I'll stop spamming your thread now. I've got what I need, and the closures are working nicely now.
Offline
nXIII wrote:
@bharvey, I made you a new signature! Like it?
I do, but I changed it a little. (Took me an hour or two; I don't think I understand transparency. Or else Graphic Converter doesn't. I finally found a way in Gimp but that wasn't easy either. ) Thanks!
PS What's with your sig? Working for Google or something?
Last edited by bharvey (2010-11-12 15:55:20)
Offline
fullmoon wrote:
the Wikipedia page on prototype OOP
... makes absolute perfect sense to me. This is exactly how Object Logo worked. That cat example doesn't seem to me to have anything to do with it except that it uses the word "prototype"!
But I guess I should just learn JS from the beginning instead of jumping in in the middle.
PS The Wikipedia discussion of delegation on that page you cited is interesting in light of our earlier conversation on the subject.
PPS You're not spamming; you're helping me think about cloning sprites in BYOB 3.1.
Offline
fullmoon wrote:
nXIII wrote:
fullmoon wrote:
What's FluxByte?We're getting really off-topic, sorry....
No, I genuinely want to know!
(Don't worry...I've singlehandedly kept this thread off topic for days.)
It's nXIII and my (I know that's probably terrible mechanics) collaboration.
Offline
shadow_7283 wrote:
fullmoon wrote:
nXIII wrote:
We're getting really off-topic, sorry....
No, I genuinely want to know!
(Don't worry...I've singlehandedly kept this thread off topic for days.)It's nXIII and my (I know that's probably terrible mechanics) collaboration.
Cool, what are you guys working on?
Offline
Stuff. We're about to release our first project. Actually, we were supposed to a couple months ago, but we had more to do than we expected.
Offline
@shadow: Hey, what did your parents say about meeting in Dallas during my conference (Sat 3/12/11)?
PS I know that sounds like a long time from now, but it affects whether I leave early that evening or stay until Sunday morning, so we have to settle it before I get my airplane tickets.
PPS By all means have them email me if they want to check me out, as in "why is this adult so interested in our kid?"
Last edited by bharvey (2010-11-13 00:08:25)
Offline
I discussed it briefly with my dad earlier, but we didn't really make any final decisions. I'm sorry if it's been an inconvenience to you. I'll talk about it more when he gets home from Germany (he's on a business trip).
Offline
shadow_7283 wrote:
I discussed it briefly with my dad earlier, but we didn't really make any final decisions. I'm sorry if it's been an inconvenience to you. I'll talk about it more when he gets home from Germany (he's on a business trip).
OK, thanks, it's not that urgent, it just can't wait until the last minute.
Offline
In order to avoid bumping this topic, let me propose a challenge that just occurred to me but I haven't really thought about it much:
Let's invent prototype-based programming in BYOB!
Any thoughts?
Oh, and unrelated request: I find it slightly annoying to do this:
Key "->" Value
to mean this:
Key -> Value
And then not be able to edit the block spec without first deleting the "-" portion.
Last edited by nXIII (2010-11-15 16:00:13)
Offline
nXIII wrote:
Let's invent prototype-based programming in BYOB!
Hint: That Wikipedia article fullmoon pointed to about prototyping says that the key to making it work is delegation.
So you just put a clone-myself method in the parent, and you put an instance variable whose value is (ask parent 'clone-myself) in the child, and you're in business!
Key -> Value
You should just be able to type this in the first place, and it certainly shouldn't give a Squeak error. http://byobugs.com
EDIT: Since nobody's responded to this, let me add a comment... Of course what you really want is to be able to define a PARENT block that only works inside an object definition, takes an object FOO as input, and inserts the blocks
SCRIPT VARIABLES <my-FOO> SET <my-FOO> TO [ASK <FOO> <clone-myself>]
into the object definition in place of itself.
Saying that another way, you want macros. So do I; in my negligible free time I'm trying to figure out how to design a UI for it. One problem is that, as in my example, you want to be able to construct variable names such as my-FOO. That means you have to be able to drop a JOIN block (or, by extension, any reporter) onto an orange blob of a SCRIPT VARIABLES to allow the name to be computable at runtime. (Jens is wincing as he reads this, I'm sure.)
EDIT 2: No, what you really really want is a way to add a method or state variable to an object that already exists. The easy part is using a table of methods inside the object instead of individual IF blocks for each message, and having a method to add methods to the table. The hard part is making all the object's methods/variables available to the script of your new method! But I guess if there's a GET <name> method in the object that gets table entries, that might do.
Last edited by bharvey (2010-11-17 00:48:20)
Offline
@bharvey
I'm working on a mini-RPG application with many characters, objects, rooms etc. I've found out interesting Byob features, new to me, simplifying the management of a crowd of sprites.
1 - for each sprite SPRITEX, you define a local variable NAME set to the name of the sprite, SPRITEX for example. As this variable is Local you can get the name of this sprite with <name OF sprite >
- in parallel you define a Global variable SPRITEX having also the name of the sprite.
Then, you can get the distance of any sprite with : DISTANCE TO [<name > OF ANYSPRITE]
2 - If you define a BROADCAST for each sprite having the name of the sprite you can pass the variable SPRITEX to BROADCAST. For example, to send a broadcast to several Sprites : FOR EACH ITEM OF LIST OF SPRITES, BROADCAST ITEM # OF LIST
3 - If you define for each sprite a method, named CO-SPRITEX, you can write :
SCRIPT VARIABLE a b
SET <b> TO SPRITEX
SET <a> to JOIN CO- <b>
RUN <a> OF <b> WITH INPUT ...
It means that you can execute "parametrable " methods by using JOIN
These features offer interest :
a - to handle a large group of sprites with LOOP instructions (MAP, FOR EACH, etc)
b - to define "objects" of a sprite in a generic manner (functions, scripts, methods, variables) this reducing the time of "adaptation" to customize a new duplicated sprite.
Offline
xly wrote:
for each sprite SPRITEX, you define a local variable NAME set to the name of the sprite
Yeah, we thought about providing a primitive block that reports the name of the sprite. But it's sort of a half-feature; really the sprite itself should be a first class value. Wait for 3.1.
Last edited by bharvey (2010-11-17 18:29:06)
Offline
@bharvey
I've uploaded (see http://www.xleroy.net/ByobTuto/thumbnails.html ) a new application RPG . It extensively uses the function CO with 4 parameters. 1st = name of the sprite which will execute the instruction; 2nd = instruction code, for example gt for GOTO, say for SAY ; 3rd and 4th parameters needed by the 2nd parameter.Byop functions are either Global or Local to one sprite. Here CO is "dedicated" to any selected sprite, this allowing any sprite to act on any other sprite.
RPG uses also PROPERTIES reporter function as explained in your Byop OOP tutorial.
Offline
@bharvey
(.../...)
One RPG is a sequence of several scenes chained by a global scenario. Each scene in itself is a "game". It is impossible to keep all these games in the Byob memory. Thus I've started to see how to export the sprite Hero with its properties from the Act I into a second application Act II. The "export" function of Hero sprite fails "Could not write file. Export failed".
It is not blocking, as the few properties values of Hero at the end of Act I can be saved into a text file to be re-imported at the beginning of Act II.
Offline
Okay, I'll look at xly's program and JD1's program just as soon as things slow down at work. And I'll perfect my prototyping OOP code, too. It may be a week or two, though; this is the end-of-semester crunch.
Offline
bharvey wrote:
@shadow: Hey, what did your parents say about meeting in Dallas during my conference (Sat 3/12/11)?
PS I know that sounds like a long time from now, but it affects whether I leave early that evening or stay until Sunday morning, so we have to settle it before I get my airplane tickets.
PPS By all means have them email me if they want to check me out, as in "why is this adult so interested in our kid?"
I'm SO sorry Brian (I guess it's OK if I call you that), but I can't come. I know this is going to sound like an empty apology, but I was really looking forward to meeting with you.
I actually brought up the Dallas conference with my dad on numerous occasions (I hadn't forgotten about it). We still hadn't had the time to plan ahead and make final decisions, and then my dad booked flights for a trip to New Zealand for three whole weeks. Unfortunately (I didn't realize it at the time) our trip was to be going on March 12.
We haven't gone to New Zealand (the country of my birth) in four years, and my dad jumped on the opportunity when fare prices dropped.
I'm really sorry, especially if this has been an inconvenience for you.
Offline
shadow_7283 wrote:
I'm SO sorry Brian (I guess it's OK if I call you that), but I can't come. I know this is going to sound like an empty apology, but I was really looking forward to meeting with you.
Bummer! I'm sorry, too. But of course your family's needs come first. You'll just have to find a way to visit Berkeley at some point.
Offline
Definitely! Possibly when I transfer in LA...?
Maybe next year.
Last edited by shadow_7283 (2010-11-29 18:22:43)
Offline