Arc Forumnew | comments | leaders | submit | greatness's commentslogin
1 point by greatness 6315 days ago | link | parent | on: Two brief ideas

Are you suggesting:

  (if (arctable "username") ... )
is somehow difficult to read? (arguable, this is an arctable and not a dictionary which is closer to an associated-list. If it were an associated-list you'd be able to do it as either:

  (if (assoc "username" arc-alist) ... )
or

  (if (alref arc-alist "username") ... )
I'd hardly call any of these difficult to understand; though perhaps assoc would make more sense if the list were the first parameter and the key the second like the alref works. i.e.

  (assoc list key)
rather than:

  (assoc key list)
Because at the minute alref and assoc are not conforming to the same standards, which make them rather awkward to use.

-----

1 point by ivankirigin 6315 days ago | link

I'm not suggesting anything about a language I don't know :)

But, the point about explicitness stands, as there is not something similar to "has_key" in the syntax in your examples.

-----

1 point by greatness 6315 days ago | link

True, but the returns are more useful (assuming has_key returns T if it has the key. I am unfamiliar with python I'm afraid).

If the current syntax is difficult to memorize, you could always write a simple function which abstracts it away into something you're more familiar with:

  (def haskey (ls key) (alref ls key))
Then you can use it:

  (if (haskey mylist "username") ... )

-----

1 point by greatness 6316 days ago | link | parent | on: Is Arc good for big projects?

This seems like it'd be closer to classes/objects than modules.

-----

2 points by nostrademons 6316 days ago | link

In JavaScript they're the same thing - objects do quintuple-duty as hashtables, records, objects, classes, and modules. Arc is very similar to JavaScript in terms of the primitive data types available - they're both Scheme-derived languages.

The reason I'd term call this modules is that they don't have the implicit-receiver that classes/objects do, nor do they have constructors. Once you define a module, that's it, and they live in the global namespace. You could change things around pretty easily so that instead of immediately executing the closure containing the module's namespace, you define it as a constructor function. And you could probably then come up with some macro to expand to a message send, which passes the object as the first argument to any method defined in it. I think you'd be stuck with explicit-self though, like in JavaScript or Python, instead of the implicit `this` of Java.

-----

3 points by mst 6315 days ago | link

... and scopes.

Javascript's scope chaining is one of my most and least favourite things about the language. But it's a damn clever approach once you get it.

-----


I believe the ordering of the colon operater was based off of the car/cdr functions work, ie:

  (def caddr (v) (car (cdr (cdr v))))
or using colon notation:

  (= caddr car:cdr:cdr)

-----

3 points by greatness 6317 days ago | link | parent | on: The real problem with unhygienic macros

The odd thing about this is that I KNOW it should break, but I can't make it do so.

  arc> (let oaf 1 (when 2 3))
  3
I'm pretty sure it is because it evaluates the macro expansion ahead of time.

  arc> (macex '(when 2 3))
  (if 2 (do 3))
Additionally, does anyone know why if isn't considered an object:

  arc> if
  Error: "reference to undefined identifier: _if"

-----

3 points by randallsquared 6316 days ago | link

The symbol 'if is a special operator, not a macro or function. The special operators in Arc's compiler are quote, quasiquote, if, fn, and set.

Probably it would be convenient to have an object tagged as a special operator for those, but it would be documentation, not functional code.

-----

4 points by pg 6316 days ago | link

Special operator is what they're called in CL. I don't know offhand what they're called in Scheme. But what it amounts to is that if only exists as a clause in the compiler.

-----

2 points by randallsquared 6316 days ago | link

"Special operator is what they're called in CL."

Yeah, I know much less about Scheme than CL, so I used the CL term.

-----

1 point by jimbokun 6313 days ago | link

What are they called in Arc? :)

-----

2 points by pg 6313 days ago | link

Special operator sounds good. Or axiom, if we want to be fancy.

-----

1 point by vsingh 6317 days ago | link

Hmm.

I guess the macros in the form are expanded with reference to the context of the entire form (the global context).

Does this mean we don't have macrolet?

-----

1 point by simonb 6316 days ago | link

It probably has more to do with if being one of the primitives (or axioms if you will).

-----

4 points by greatness 6318 days ago | link | parent | on: The proposed : syntax

(A) That looks suspiciously like python. (B) If it IS implemented at some point, I would not be against it, but that colon better be optional :p

-----

3 points by fmota 6318 days ago | link

(A) I love python. ;)

(B) Makes sense. After all, if you're going through the troubles of adding indentation, you might as well make the colon optional.

-----