Arc Forumnew | comments | leaders | submitlogin
Babel (Bipedal): response to fallintothis
3 points by claytonkb 4221 days ago | 4 comments
I just saw your reply from a long time back @ http://arclanguage.org/item?id=18020 ... thanks for your feed back and my apologies for not replying sooner.

"Very interesting! Particularly the <- and -> operators. It's refreshing to see new approaches to stack shuffling that don't come from the kind of established zeitgeist of stack shufflers (dup, swap) & combinators (dip, bi, tri). I was confused by the notions of the "downstack" and "upstack", because it looks to me that you really only have one stack, and a cursor into it,"

This is conceptually correct, but the stacks are maintained separately so when I refer to "two stacks" I'm referring to an implementation detail. Based on your feedback, I'll update the documentation to make this clearer.

"Also, it seems to me the language isn't really "typeless"; rather, the programs aren't generally type-directed."

I do not mean "typeless" in any kind of rigorous sense. It is not type- enforced. There are, of course, implicit types within the language since applying the wrong operators to the wrong data will produce gibberish or even cause the interpreter to fail. Right now, it is fairly easy to induce the interpreter to crash. Later on, the interpreter will have more safety checks to protect against type errors that can result in an interpreter crash.

"The system appears similar to Arc's, where you have a few already-used type tags (string, int, num), but in principle the tags are arbitrary. I suppose one distinction could be the treatment of the data under certain operations: Bipedal has syntax for strings and integers, but what happens when you call + on a string and an integer? Is it just treated like adding the string's address with the integer, perhaps?"

No, both the string and the integer are stored at "the same level of dereference", so to speak. So {'a' 1 +} will actually work and the result will be 0x62 (the ASCII code of 'b'). Note that:

  {'b' 'a' 1 + =}   -- '=' denotes comparison, not assignment
... will evaluate to not-equal. The reason is that 'b' is encoded as an "array-8" which means that it gets an additional mword to show the alignment of the string (since there are 4 bytes per mword on a 32-bit machine, etc.) This is called the "alignment word" in the documentation. The + operator, however, does not create array-8 output, it just creates a new mword and puts the sum of the first entry of TOS and TOS-1 into the new mword. Here's a debugger output showing the execution of the above code:

  > t    <-- (t means "step and show dstack"
    (val 0x62 0xffffff00 )
  
  > t
    (val 0x61 0xffffff00 )
    (val 0x62 0xffffff00 )
  
  > t
    (val 0x1 )
    (val 0x61 0xffffff00 )
    (val 0x62 0xffffff00 )
  
  > t
    (val 0x62 )   <--- notice the result of + doesn't have the ..fff00
    (val 0x62 0xffffff00 )
  
  > t
    (val 0x1 )    <-- 1 means "not equal" b/c this is C's memcmp()
  
  > q
  
As a side note, you can use a trick to get what you "expect" in the case of adding 1 to 'a' (that is, 'b'):

  {'a' 1 +=}
The "add and assign" operator will add "in-place" without allocating new memory for the result. Thus, you get 1 added into the 'a' to give 'b':

  > t
    (val 0x61 0xffffff00 )
  
  > t
    (val 0x1 )
    (val 0x61 0xffffff00 )
  
  > t
    (val 0x62 0xffffff00 )  <-- 'b' as "expected"
  
  > q
  
As in C, this is not a feature or a bug... it's just something that is possible but probably doesn't ever really make sense to do. Should it warn? I don't know, but it will definitely be possible to make it warn if that's something you care about... at the cost of performance, of course.

"Finally, I'm interested by the crypto angle. Do you think this is just a generally important (or interesting) feature, or is there a particular application you have in mind? [I said, hoping you're still checking this forum. :)]"

I think it's generally important. I hope to one day leverage the crypto capability to build an Babel-driven client-side encrypted virtual file- system for "cloud" computing (scare-quotes because cloud is a particularly obtuse buzzword, IMO).

Do check in on my website (babelscript.net) from time to time as I will be updating it as I go. I'm a stickler for documentation but it's of course very difficult to keep the docs up-to-date. The more people who read the website, however, the more motivated I will feel to make sure everything is up-to-date.

Clayton -



2 points by fallintothis 4212 days ago | link

Now it's my turn to comment back after awhile, ha. Thanks for the replies!

I don't have much to add. Your explanation of the type system, such as it is, makes more sense now. Could sit here splitting hairs all day over whether to call it "weakly typed" or "untyped" or whatever other term, but it makes sense at the end of the day when you put it in terms of the (val 0xXX 0xXX) stuff.

Am I right in basically reading that like (val [value] [tag])? And then, the idea is that all operators (not just +) operate on the "value" part of these "value x tag" tuples? Destructive operators preserve the tag, because they're also just operating on the "value" part, but of the same structure. Whereas nondestructive operators need to create a separate (val ...) structure, and don't set the tag. So would

  {'b' 'a' +}
evaluate to 0xc3, since that's 0x61 + 0x62 and the type tag is unpreserved, despite being (presumably) the same (since they're both strings)?

Sorry to ask all these questions that would probably be better answered by me playing with the language myself or looking at the docs. It's an easy---but surely annoying---way to make conversation. Feel free to "RTFM" me. :)

P.S.:

"cloud" computing (scare-quotes because cloud is a particularly obtuse buzzword, IMO).

Hey, preaching to the choir, brother!

-----

1 point by claytonkb 4221 days ago | link

N/A

-----

2 points by rocketnia 4221 days ago | link

If what you want is a block of preformatted code, indent each line by two spaces.

  abc
  def
  ghi
At this point, I think you still have time to go back and edit. I think your points are pretty clear either way though. :)

More formatting instructions are here: http://arclanguage.org/formatdoc. This page appears via a "help" link when editing a post.

-----

1 point by claytonkb 4220 days ago | link

Thanks :)

-----