Re: comments on my design of a new language?
- From: ryanlowe0@xxxxxxxxx
- Date: 16 Jan 2006 12:18:14 -0800
> Not sure I'm following here. What types are there? Trees, Lists, Regular
> Expressions and Scalars? Dictionaries are trees of height 1? Arrays are
> lists? Trees are unordered? Lists are ordered? Trees are indexed by the
> names of their nodes (like a hashtable)? Lists are indexed by integers
> representing the element's position in the list?
> Is a String a scalar, or is it a list of scalars?
Oliver, Ive made a few changes since my last explanation. I have
decided to make trees 1st-class, and I am thinking about moving regular
expressions back to library status to keep things as clean as possible.
So the current types are scalars (a single number or string), trees,
arrays, and functions. The names of the child nodes of a tree node can
be made into a list by trailing[]. Since I am making trees 1st-class,
they can be used as values in an array just like the other types. I do
want to maintain the homogeneity requirement, however. And there are
technically no arrays of arrays, just multi-dimensional arrays. This
means you cant have a matrix where different rows contain different
numbers of columns. You can get this behavior by including nil elements
in some positions. nil will automatically coerced to zero or the empty
string where necessary.
> >> What about the following?
> >> a = x!do1():do2()!do3():do4()!do5()
> >> Here, do1() modifies x, do2() acts on a copy of x, and that copy gets
> >> stored
> >> into a. do3() then modifies the copy. do4() then makes a copy of that
> >> copy.
> >> do5() then modifies the copy of the copy, but the value is lost, because
> >> it
> >> doesn't get stored anywhere.
> > I dont see why you would think the value would get stored to a after
> > do2(). I would want assignment with = to always be the last operation.
> > I want to thank you for the example, though. The system does allow some
> > wacky operations that a sane programmer would probably want to avoid,
> > but its good to test the limits.
> I guess my questions then are, in the above example: what gets store in
> x? what gets store in a? What happens to the return value of do1()? What
> happens to the return value of do2()? etc. up to do5()?
a = x!do1:do2!do3:do4!do5
In this statement (the trailing() are redundant), the result of do1 is
stored to x. This same value is then passed to do2. After that, I think
it should raise an error because you cant assign a value to a function
call, which is what !do3 is trying to do. Likewise you cant assign to a
literal value, so this is also illegal: [1,2,3]!count
> >> [[1, 2], [3, 4]] + [1, 3] = [[1, 2] + 1, [3, 4] + 3] = [[1 + 1, 2 + 1],
> >> [3 +
> >> 3, 4 + 3]] = [[2, 3], [6, 7]]
> >> This last one doesn't match your example, which says that the result
> >> should
> >> be [[2,5],[4,7]].
>
> > They seem to match to me. I really am just stealing the behavior
> > directly from numarray. If it works their, it will work in my language;
> > if not it wont.
> If I apply my interpretation of the rules above, I get the result [[2,
> 3], [6, 7]]. According to your example, the results should be [[2,5],[4,7]].
> These two values aren't the same, which is why I say they don't match.
I didnt really follow that example with multiple = signs. The basic
rule is that arrays must have *compatible* dimensions. Scalars are
always compatible.
[[1, 2], [3, 4]] + [1, 1] # ok
[[1, 2], [3, 4], [5, 6]] + [1, 1] # ok
[[1, 2, 3], [4, 5, 6]] + [1, 1] # bad
[[1, 2], [3, 4]] + 1 # [[2, 3], [4, 5]]
[[1, 2], [3, 4]] + [1] # same result
> If you just flatten the lists, and lists can contain lists, what if you
> try to flatten a list which contains itself?
Lists (arrays) can not contain other arrays, as I mentioned above.
> >> But what if the children of "new" were something other than strings or
> >> numbers? What if they were lists, or dictionaries, or regular expressions
> >> themselves? How do you match a regular expression against a regular
> >> expression?
>
> > Functions only work on literals, literal arrays, or tree lists that
> > have no nonterminal children. As for regular expressions, you got me
> > thinking. Though it is not something most people would have use for, I
> > have always wanted a mechanism for generating a random string that
> > obeys a regular expression rule. Perhaps when a regex is used where a
> > string is expected, I could have it do just that.
>
> Your language would then be a non-deterministic one, which isn't
> inherently a "bad" thing per say, but I think most developpers, for
> "serious" work, prefer a deterministic language.
>
> You could convert a regular expression to the "simplest" string which
> would match it (which will probably often turn out to be the empty string).
Again, I am getting rid of the builtin regexs. I still might add a
function to generate a random string:
print regex_string:re.random
.
- References:
- comments on my design of a new language?
- From: ryanlowe0
- Re: comments on my design of a new language?
- From: Oliver Wong
- Re: comments on my design of a new language?
- From: ryanlowe0
- Re: comments on my design of a new language?
- From: Oliver Wong
- comments on my design of a new language?
- Prev by Date: Re: comments on my design of a new language?
- Next by Date: Re: comments on my design of a new language?
- Previous by thread: Re: comments on my design of a new language?
- Next by thread: Re: comments on my design of a new language?
- Index(es):
Relevant Pages
|