Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

carry on then posted:

ok now do this for the whole windows os

easy peasy

Star War Sex Parrot posted:

hell yeah check out the sweet invariants I wrote for my hash table
code:
  type hashtbl 'a = {
    mutable size: int ;
    mutable data: data 'a ;
    ghost mutable model: model 'a }

    invariant { length self.data > 0 }
    invariant {
      forall u:key. forall v:'a.
      mem (u, v) self.data[bucket u (length self.data)] <->
      Map.get self.model u = Some v }
    invariant {
      forall u:key. forall v:'a. forall w:'a.
      (mem (u,v) self.data[bucket u (length self.data)] /\
      mem (u,w) self.data[bucket u (length self.data)]) ->
      v = w }
    invariant {
      forall i: int. 0 <= i < length self.data ->
      forall u: key, v: 'a. mem (u,v) self.data[i] ->
      bucket u (length self.data) = i }
proving these during resize was sort of a bitch. this is the signature and contracts for a resize function whose body is like 6 lines
code:
    let rec rehash (new_data : data 'a) (l : bucket 'a) (ghost i : int) : unit =
      requires {
        forall j: int. 0 <= j < new_size ->
        forall u: key, v: 'a. mem (u,v) new_data[j] ->
        bucket u new_size = j }
      requires {
        forall u: key, v: 'a. mem (u,v) l ->
        bucket u old_size = i }
      requires {
        forall u:key. forall v:'a.
        0 <= bucket u old_size < i ->
        (mem (u, v) new_data[bucket u new_size] <->
        Map.get t.model u = Some v) }
      requires {
        forall u:key. forall v:'a.
        bucket u old_size = i ->
        (Map.get t.model u = Some v <-> mem (u, v) l \/
        (mem (u, v) new_data[bucket u new_size])) }
      requires {
        forall u:key. forall v:'a.
        bucket u old_size > i ->
        not (mem (u, v) new_data[bucket u new_size]) }
      requires { new_size = length new_data }
      ensures {
        forall j: int. 0 <= j < new_size ->
        forall u: key, v: 'a. mem (u,v) new_data[j] ->
        bucket u new_size = j }
      ensures {
        forall u:key. forall v:'a.
        0 <= bucket u old_size <= i ->
        (mem (u, v) new_data[bucket u new_size] <->
        Map.get t.model u = Some v) }
      ensures {
        forall u:key. forall v:'a.
        bucket u old_size > i ->
        not (mem (u, v) new_data[bucket u new_size]) }
      variant { l }

this is what all programming will be like when HP Hovercraft has his way

Adbot
ADBOT LOVES YOU

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

MALE SHOEGAZE posted:

i'm going to learn F# i think. does it still require that you declare your functions before using them within the same lexical scope? or was it something weird about file names? i cant remember.

I think people were confused by F# because it uses in-order evaluation, like Lisp or ML or Haskell, rather than a C-like independent/static compilation model

so code within files needs to be ordered and the files themselves need to be ordered as well

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Colonel Taint posted:

Is this true of all fp? Like I've mainly done programming in the small type stuff for course work in scheme, sml, and some racket so I haven't had to deal with this, but it sounds hosed up.

e: Possibly less hosed up than having to worry about link order with large C projects though, now that I think about it.

a lot of languages and environments are like this, not just functional ones

the main difference is if what you’re writing is a static description of a system (C, C++, ObjC, Java, C#, Swift) or whether the system is effectively “live” while it’s being compiled (Lisp, Scheme/Racket, Smalltalk, ML, etc.—and JavaScript)

having the system be “live” during compilation can be an advantage, for example you can use its full power at compile time via macros or other forms of metaprogramming

  • Locked thread