Arc Forumnew | comments | leaders | submit | tung's commentslogin
2 points by tung 5722 days ago | link | parent | on: Why I think Arc should use packages

I don't think there's anybody here that doesn't think that Arc should have packages.

I personally don't mind how packages are done so long as they're simple and transparent.

-----

3 points by drcode 5721 days ago | link

I don't think arc should have packages.

My preferred solution, FYI, would be some kind of crazy thread-specific namespacing. Then, by having large numbers of light-weight threads, name collisions wouldn't be an issue anymore. (Yes, you could say this is similar to a module system, if you want to be pedantic :-)

-----

2 points by almkglor 5721 days ago | link

> My preferred solution, FYI, would be some kind of crazy thread-specific namespacing.

The devil is in the details.

-----

2 points by tung 5765 days ago | link | parent | on: Objects in Arc

I'd do it like this:

    function Person(first, last, age) {
        this.first = first;
        this.last = last;
        this.age = age;
    }
    
    Person.prototype.full = function () {
        return this.first + " " + this.last;
    };
    
    Person.prototype.until = function (year) {
        return year - this.age;
    };
You shouldn't really put functions inside the constructor function unless you really need the closure.

-----

1 point by gnaritas 5759 days ago | link

Which is handy if you want private instance variables. But you're right, prototype should be the first choice, like I said, it's been a while.

-----

1 point by tung 5765 days ago | link | parent | on: Python-like modules

Nice. I always wanted to see Python-style packages in Arc: simple, but gets the job done.

-----

1 point by tung 5803 days ago | link | parent | on: Why Arc is good for video games

It may not be pure OpenGL, but my OpenGL book says that glXUseXFont will load an X font, which builds a bunch of display lists, each one of which containing a character rendered with that font.

I'm curious though. Why OpenGL? SDL plus SDL_ttf could have handled things just as well, plus Y would have pointed down, not up.

-----

2 points by kens 5803 days ago | link

PLT Scheme's OpenGL interface doesn't support glx, so I couldn't use glXUseXFont.

What are SDL and SDL_ttf? Is there any way to use them from Arc?

-----

4 points by tung 5802 days ago | link

http://www.libsdl.org/

Simple DirectMedia Layer. Cross-platform multimedia library that has audio, input and 2D graphics. SDL_ttf is a standard extension to it that provides TrueType font support. If Arc can load C libraries, it can should be able to load SDL.

-----

1 point by stefano 5802 days ago | link

In anarki, you can use ffi.scm to import C functions.

-----

1 point by tung 5804 days ago | link | parent | on: What's next?

How do Haskell's modules differ from Python's?

-----

2 points by applepie 5804 days ago | link

Python's modules are first class. For example:

  import module

  x = module
  x.function(...)
In Haskell, names are resolved during compile-time...

Also, in Haskell modules can define which names to export. In Python everything is visible.

-----

3 points by tung 5805 days ago | link | parent | on: When is the next Arc-version coming out PG?

Good to see you're still around. Things were getting scary there for a while.

-----

4 points by tung 5814 days ago | link | parent | on: Don't understand how macros work

It's risky to say "you should do X" or "you shouldn't use Y" when talking about using programming languages, because they don't look at the problem being solved. Using variables may be a very natural way to approach problem A, while they'd be very clunky for problem B.

There are places where even goto is useful.

-----

2 points by jmatt 5814 days ago | link

I am asking because it is a common mistake when moving from an imperative language to a functional language. I know I made the mistake of trying to use many variables when I first started writing functional code. I was asking so that I could help out.

I never said "you shound do ..." or "you shouldn't use ...".

I have no problem with people using whatever style or approach that they want. If you want to write arc with gotos and a bunch of variables, go for it. I just wanted to help this arc coder out.

-----


The system uses some sort of equation based on the submission time and points of each topic to determine the topic ordering. Changing that equation to use the last response time of each topic would do it.

-----


I've stumbled into this too. I got around it by aliasing self outside of the each form, but yeah, it looks like a bug.

-----

2 points by tung 5881 days ago | link | parent | on: A fix for arc's gensyms

The arc implementation doubles as the specification. Piggy-backing on mzscheme's gensyms seems like an attractive prospect at first, until you realise that we now have a part of arc which isn't defined in arc. The only way that could work is if gensym becomes considered as a language axiom, and I'm not sure if it's really a candidate for that.

In practice, I wouldn't believe to be that much of a problem. Who would want to mimic the abominable symbols generated by arc with the current methods anyway, intentionally or otherwise?

-----

1 point by eds 5881 days ago | link

You have a good point there. Fortunately it can be fixed trivially, by returning the definition of 'ar-gensym to its original form and using 'string->uninterned-symbol instead of 'string->symbol. (I suspect this is what mzscheme 'gensym does anyways.)

  (define (ar-gensym)
    (set! ar-gensym-count (+ ar-gensym-count 1))
    (string->uninterned-symbol (string-append "gs" (number->string ar-gensym-count))))

-----

More