Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
breuleux
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
49 ms
·
511.
▲
by
breuleux
12y ago
It's obvious that many subjects would release the AI, if only because they don't really know why it's in a box in the first place. Furthermore, the experiment grants AI capabilities it would probably not have, such as read&#x
512.
▲
by
breuleux
12y ago
A lot of Asimov's work deals with loopholes and inadequacies in these laws, though: for instance, what is a human being? Does surgery violate the first law? If a human is going to injure another human, can the first law be overridden?
513.
▲
by
breuleux
12y ago
Skimming Dreyfus's criticism, it is mostly applicable to early AI research which tried to reproduce intelligence through high level symbolic manipulation and rule-based systems (and he was right: that approach failed). Modern AI resear
514.
▲
by
breuleux
12y ago
I think there is one reason to default to something ordered, which is that iterating through unordered hashmaps can be non-deterministic from one run to the other. For instance, if you hash by id, the same objects may be assigned different
515.
▲
by
breuleux
12y ago
I know that variable names in Python's AST can be any string, so for instance you could declare and use a variable named "+a-b$ $$?", even though that's not valid Python code. That's pretty minor, though, so I'
516.
▲
by
breuleux
12y ago
> This is a real hairy example IMO since it's conflating the mechanics with optional parenthesis and dot-less method calls, but we can break it down just the same. Since Int.+ takes a single argument, then it must parse as: >
517.
▲
by
breuleux
12y ago
> The underscore isn't a placeholder saying "inject a Function here". It is . Look at the error message: error: missing parameter type for expanded function ((x$1) => x$1.$times(2)) It did inject a function, i
518.
▲
by
breuleux
12y ago
That's interesting, but you did not answer my question. I wanted to know how Scala determines where to insert =>. In my example, Scala interprets "ary.map(f(_ * 2))" as "ary.map(f(x => x * 2))" (both of these
519.
▲
by
breuleux
12y ago
This is not a confusing context, though. This would be a confusing context: ary.map(f(_ * 2)) ==> ary.map(x => f(x * 2)) ? ==> ary.map(f(x => x * 2)) ? How does Scala interpret that one? I have no idea.
520.
▲
by
breuleux
12y ago
Personally I would go for something more like this: STDIN | /\w+/ | {|each match| /house/ => "foo" /car/ => "bar" "literal" => "baz"
521.
▲
by
breuleux
12y ago
You can still have simpler table syntax that's nice to read but easier to maintain. For my own markup language ( http://breuleux.net/quaint_demo/ ) I implemented this syntax: + Name + Occupation | Alice
522.
▲
by
breuleux
12y ago
I installed spider-script through npm, but `spider somescript.spider` complains with $traceurRuntime not being defined. I can still compile the script, then require traceur and the script from another file, but I'd rather not have to d
523.
▲
by
breuleux
12y ago
Good point. It's important to properly highlight the focused window on desktop so that it's clear where keyboard input goes, and in the screenshots it doesn't look like they do that. I hope the final product fixes that.
524.
▲
by
breuleux
12y ago
> really bright colors in the top bars: that's exactly what we _don't_ want in desktop apps, as the focus is on the (changing) content, not the title bars Bright colors serve as good visual anchors. If you have a lot of windows
525.
▲
by
breuleux
12y ago
Actually, no: if you run this you will see three matching groups, but the first is always the whole match (this is in addition to the capture groups that are defined), the second is the (redundant) capture group you put around the whole t
526.
▲
by
breuleux
12y ago
The match object will be of the form [undefined, ..., input_string, undefined, ...], so you can use something like m.indexOf(input_string) to find out the index. Unfortunately that's O(n) again, unless the engine uses a sparse array im
527.
▲
by
breuleux
12y ago
Typically, what I do is just map the indent and dedent tokens directly to some suitable bracket pair, so the implementation is trivial. As for the infinite arguments, well, as a language designer, is that really your problem? I mean, that k
528.
▲
by
breuleux
12y ago
You can easily allow both, though. At worst you can simply turn off significant indent inside explicit delimiters.
529.
▲
by
breuleux
12y ago
Not a lot of work. I have implemented pattern matching before, so I just went ahead and did it: http://jsfiddle.net/f1ycatas/2/ See line 266 for the syntax definition (the precedence entry for "->" on
530.
▲
by
breuleux
12y ago
The AST viewer is not included in the 450 lines, although the comments are. Most of the difference is due to the more sophisticated parser and some extra features like arrays.
531.
▲
by
breuleux
12y ago
That's pretty cool :) To be fair, though, the 450 lines include about 120 lines of comments, a configurable full operator precedence parser, syntax for array creation and indexing, range and looping operators, short-circuit logical ope
532.
▲
by
breuleux
12y ago
Indeed, that is a very good article. I highly recommend it. TDOP is the combination of recursive descent and Floyd's operator precedence grammars, the latter of which is the technique I used (I find it sufficient for my needs).
533.
▲
by
breuleux
12y ago
Postfix operators do work. Try this: let x! = if x == 0 then 1 else x * (x - 1)! end in 5! end Any operator can be prefix, infix or postfix depending on the relative priority with the operators next to them. For instance, in "
534.
▲
by
breuleux
12y ago
I agree I should post one, but it usually takes me a lot of time, and I wasn't sure how much interest there would be. I'll start working on one.
535.
▲
A programming language in 450 lines of JavaScript
(jsfiddle.net)
316 points
by
breuleux
12y ago
|
70 comments
536.
▲
by
breuleux
12y ago
I have gone the other way with the languages I designed, from the system you describe to multifix, and have had the opposite experience. A proper implementation of general operator precedence grammars is much simpler than implementing pre
537.
▲
by
breuleux
12y ago
Multifix is more general than a combination of infix, prefix and postfix, though. For instance, a [] block is a multifix operator, but you can't implement it as a combination. The advantage of supporting multifix directly is that you g
538.
▲
by
breuleux
12y ago
Yeah that puzzles me a bit too. Multifix operators are not more complicated than prefix/postfix/infix (well, only marginally). For instance, you can give each operator a left priority and a right priority and merge them when the
539.
▲
by
breuleux
12y ago
I designed the Earl Grey language ( http://breuleux.github.io/earl-grey/repl/ ) on pretty much exactly the same principle, it's pretty interesting to see someone else had the same idea. Operator precedence gram
540.
▲
by
breuleux
12y ago
Well, the idea of zones is that the second zone depends on the first zone, the third depends on the second, and so on. It is meant to allow definition and use of a language within the same file, so there is little point in having a differen
More ›