Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting XML code is <ref id=whatever the object's ID stored in the table is/>
Offline
joefarebrother wrote:
Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting XML code is <ref id=whatever the object's ID stored in the table is/>
Thanks, that makes sense. So it's not object specific? That's what confused me.
Offline
dreamod wrote:
joefarebrother wrote:
Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting XML code is <ref id=whatever the object's ID stored in the table is/>
Thanks, that makes sense. So it's not object specific? That's what confused me.
It's specific to that list, is it not?
Offline
blob8108 wrote:
dreamod wrote:
joefarebrother wrote:
Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting XML code is <ref id=whatever the object's ID stored in the table is/>
Thanks, that makes sense. So it's not object specific? That's what confused me.
It's specific to that list, is it not?
If you get Jens to explain it it will be more clearer
Offline
object IDs is something we don't have in BYOB, because Scratch doesn't have (need) them. But we need them on order to deal with circularity, because we have first-class lists.
The idea is to give every object a unique identifier when it's being stored. At first the identifier is nil, but when you first touch it to store it, you increment a counter and assign it to the object's identifier. Then when you come across an object you've already stored (which you recognize because it already has the id set to something other than nil) you don't store it again, but instead you just store a reference to that object. That reference is the object's ID.
In Smalltalk it's very hard to add object attributes on the fly, so it's probably best to add another instance variable (how about "serialization_id" to the Object class, or to use the existing object's #hash as an ID.
Offline
Jens wrote:
object IDs is something we don't have in BYOB, because Scratch doesn't have (need) them. But we need them on order to deal with circularity, because we have first-class lists.
The idea is to give every object a unique identifier when it's being stored. At first the identifier is nil, but when you first touch it to store it, you increment a counter and assign it to the object's identifier. Then when you come across an object you've already stored (which you recognize because it already has the id set to something other than nil) you don't store it again, but instead you just store a reference to that object. That reference is the object's ID.
In Smalltalk it's very hard to add object attributes on the fly, so it's probably best to add another instance variable (how about "serialization_id" to the Object class, or to use the existing object's #hash as an ID.
Thanks. By the way, what is the color property? Pen color?
Offline
@bharvey: Dug out my old Scheme interpreter I was writing a few months ago this morning. I tinkered with it, then uploaded it to gdocs. I figured you'd want to check it out. Here's the link.
EDIT: My favorite program is the NQueens solver: input (@run "Examples/queens")
Last edited by Hardmath123 (2012-10-19 06:39:14)
Offline
@bharvey: posted this on another thread, Hardmath thought it might amuse you...
@Hardmath123: this seems cool! I like the pretty colours Although I haven't used nearly enough LISP/Scheme/whatever to try it out properly...
Last edited by blob8108 (2012-10-19 14:40:20)
Offline
blob8108 wrote:
@bharvey: posted this on another thread, HardMath thought it might amuse you...
@HardMath123: this seems cool! I like the pretty colours Although I haven't used nearly enough LISP/Scheme/whatever to try it out properly...
Thanks!
P.S. I'm Hardmath. Lowercase m: sometimes people call me math to distinguish from Math (MathWhizz).
Offline
Hardmath123 wrote:
P.S. I'm Hardmath. Lowercase m: sometimes people call me math to distinguish from Math (MathWhizz).
Got it. All my posts mentioning you duly updated.
Offline
Check out Snap! in Japanese and http://snap.berkeley.edu/snapsource/sna … ng:ja_HIRA, both by the amazing Kazuhiro Abe!
Last edited by Jens (2012-10-22 14:13:11)
Offline
Jens wrote:
Check out Snap! in Japanese and http://snap.berkeley.edu/snapsource/sna … ng:ja_HIRA, both by the amazing Kazuhiro Abe!
The http block and the two Unicode blocks are still in English. Other than that... I don't know any Japanese so I can't tell you if they are translated correctly.
Offline
joefarebrother wrote:
Jens wrote:
Check out Snap! in Japanese and http://snap.berkeley.edu/snapsource/sna … ng:ja_HIRA, both by the amazing Kazuhiro Abe!
The http block and the two Unicode blocks are still in English. Other than that... I don't know any Japanese so I can't tell you if they are translated correctly.
Japanese readers and writers use roman letters for some words of foreign origin (as in http and Unicode) in addition to two phonetic alphabets and characters.
I read enough Japanese to assure you that they are an outstanding draft that will improve as the English keys continue to mature.
The bigger implication of this milestone is that it is the first fully Unicode translation that shows Snap can now be translated for a much broader range of world languages.
Last edited by scspaeth (2012-10-23 13:14:50)
Offline
Snap! is quickly becoming ever more internal. Check it in Korean and in Portuguese!
Offline
Jens wrote:
Snap! is quickly becoming ever more internal. Check it in Korean and in Portuguese!
I am excited to see these contributions. I hope they develop into equally enthusiastic Snap! user communities.
I'm curious to know how the addition of these language files influences both machine requirements and performance of Snap. As you have it set currently, the snap.html loads all lang-xx.js files. So, it takes a little longer to start Snap but it uses only one translation dictionary at a time.
Are there any advantages to turning language loading scripts of languages I don't know into comments on my local copy of Snap?
Disadvantages?
Offline
Naw, they're just a bunch of dictionaries containing a limited number of strings. This is the 21st century where a single photograph is bigger than all of Snap, including all the language translations you can think of. We're in the GUI business, if we wanted to worry about conserving machine resources we'd use Scheme.
Still, you're right. Ideally we'd dynamically load only the single translation which is currently needed. I've done some experiments with this, but they all turned out to be significantly slower and much more instable than what we have now. And don't forget: In regions of the world where you're neighbors speak a different language than you it's really nice to be able to frequently switch between languages just to learn something about the *language* (not the programming language).
Offline
Jens wrote:
I've done some experiments with this, but they all turned out to be significantly slower and much more instable than what we have now.
var script = document.createElement('script'); script.src = 'lang-de.js'; script.onload = function () { // update UI… }; document.head.appendChild(script);
Will work in all modern browsers.
Offline
You've asked for it: Morphic.js, Snap's central component and GUI engine, now on Github: https://github.com/jmoenig/morphic.js
Offline
Thanks, nXIII, that's a very good suggestion, and a lot easier to accomplish than what I had in mind! The only problem left is how to touch each file once to retrieve the language "header" info (lanugage name, translator credentials) before actually loading all of it later.
Offline
Jens wrote:
The only problem left is how to touch each file once to retrieve the language "header" info (lanugage name, translator credentials) before actually loading all of it later.
The only way to really accomplish that is to put that information in a separate file, or to make some server-side cleverness to do it for you.
Last edited by nXIII (2012-10-27 09:11:17)
Offline
Jens wrote:
You've asked for it: Morphic.js, Snap's central component and GUI engine, now on Github: https://github.com/jmoenig/morphic.js
Jens:
Thank you. This is yet another reason it is so gratifying to participate in this project. I not only get a chance to stand on others' shoulders, I get to see incremental process, learn by doing and reflect on it, too!
Wikipedia: Standing_on_the_shoulders_of_giants
-----------
Stephen Spaeth
Offline
nXIII wrote:
Jens wrote:
The only problem left is how to touch each file once to retrieve the language "header" info (language name, translator credentials) before actually loading all of it later.
The only way to really accomplish that is to put that information in a separate file, or to make some server-side cleverness to do it for you.
Or use XHRs cleverly, I suppose.
Offline