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
jony neuemonic
Nov 13, 2009

JawnV6 posted:

now im wondering if this type system has enough gearing to check int Adder(int, int) is actually an adder without deigning to actually run the stupid function with an argument or two

maybe we're talking past around 'need' though

i mean, i'm definitely hamming it up a bit because yospos but my point wasn't static typing = no unit tests ever, it was that you have to write and maintain fewer of them when you can encode the basic poo poo in the type system. and that's with a pretty dumb java/c#-style system, i'm sure the ml and f# wizards in the thread can cram at least half their business rules into type definitions.

like, look at this stuff. it's bananas.

Adbot
ADBOT LOVES YOU

JewKiller 3000
Nov 28, 2006

by Lowtax
lol that's not bananas that's standard ml/f# technique. i was expecting at least a gadt or something weird haha

but yeah that's a good example of how to make the type system do your work for you

Gul Banana
Nov 28, 2003

hobbesmaster posted:

q: in c++11 can you use a range based for loop to modify a vector<bool> in place?
a: sure! its just:
code:
vector<bool> foo;
... //stuff with foo
for(auto &&x : foo){
    x = !x;  //or whatever other operation you want!
}
q: wait what what the gently caress is the type of x in that loop?
a: ¯\_(ツ)_/¯

man, it's obviously a std::_Vb_reference<std::_Wrap_alloc<std::allocator<unsigned int>>>. what's so weird about that

Sapozhnik
Jan 2, 2005

Nap Ghost

Luigi Thirty posted:

holy poop this is way better than the x86 nightmare

this is not a high bar to clear

the PDPs and then the m68k archiectures are the canonical examples of cisc architectures. x86 isn't a canonical example of cisc or risc, it is a canonical example of a directionless mess dragged along by inertia.

cisc instructions are very slow compared to risc instructions, but they do a lot more. the big selling point of risc poo poo was "well, we have compilers now so we don't need to make ISAs nice to program by hand, we need to make them nice for compilers to target and for chip designers to implement". except that doesn't really hold up that well in practice because risc instructions take up way too much precious instruction cache space so the architectures people think of as "risc" these days have a whole bunch of redundant instructions that act as shorthand for common tasks like function prologs/epilogs etc

really these days the only thing that risc means any more is "you can only access memory using explicit loads and stores".

Sapozhnik fucked around with this message at 19:43 on Aug 13, 2016

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I spent all afternoon writing a 68k program that takes console input and displays an 8-digit number on the LEDs in easy68k

I will never reproduce

jony neuemonic
Nov 13, 2009

JewKiller 3000 posted:

lol that's not bananas that's standard ml/f# technique.

christ, i clearly need to start using some f#.

Notorious b.s.d.
Jan 25, 2003

by Reene

Luigi Thirty posted:

I spent all afternoon writing a 68k program that takes console input and displays an 8-digit number on the LEDs in easy68k

I will never reproduce

you say that like it's a bad thing

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Notorious b.s.d. posted:

you say that like it's a bad thing

why am I autistic for old technology instead of up to date technology

Notorious b.s.d.
Jan 25, 2003

by Reene

Luigi Thirty posted:

why am I autistic for old technology instead of up to date technology

who cares

writing DOS raycasters and m68k assembly will teach you the same poo poo anyway

Notorious b.s.d.
Jan 25, 2003

by Reene
reproduction is overrated

1980s cisc is sorely under-appreciated

you're doing god's work

Luigi Thirty
Apr 30, 2006

Emergency confection port.

it's not a raycaster it's a full 3D engine lol

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

MALE SHOEGAZE posted:

if you have to call this.SomeGlobal, its not a global. it's a member of this. 'this' is an implicit argument, but an argument nonetheless. maybe I'm not following, but you seem to be complaining about instance state and not global state. i mean, still annoying.

i think you underestimate just how bad javascript's scoping rules are

code:
x = 10
function foo() {
  var x = 5
  console.log(x)
  console.log(this.x)
}
foo()
first console.log() prints the local x, second prints the global x.

abraham linksys
Sep 6, 2010

:darksouls:

Plorkyeran posted:

i think you underestimate just how bad javascript's scoping rules are

code:
x = 10
function foo() {
  var x = 5
  console.log(x)
  console.log(this.x)
}
foo()
first console.log() prints the local x, second prints the global x.

lol just lol if you don't "use strict" in tyool 2016

code:
$ node --use_strict
> x = 10
ReferenceError: x is not defined
    at repl:1:3
> function foo() {
...   var x = 5
...   console.log(x)
...   console.log(this.x)
... }
undefined
> foo()
5
TypeError: Cannot read property 'x' of undefined
    at foo (repl:4:17)
    at repl:1:1
anyways here's what's going on there: this inside a closure in non-strict mode defaults to the window object (or global object in node). this was recognized as an insanely bad decision, so in strict mode, this in a closure defaults to undefined.

if you have code that relies on this referring to the global namespace inside a function body you should either fire everyone involved in writing it or quit

further reading i'd recommend: http://www.2ality.com/2014/05/this.html

abraham linksys fucked around with this message at 04:40 on Aug 14, 2016

Luigi Thirty
Apr 30, 2006

Emergency confection port.



i wanted to do some more 68k assembly so i wrote a little program that will read a floppy image and enumerate the root directory. auto-looping branch instructions are great

took me a little while to figure out how to read a 32-bit little endian number (all FAT12 data is little endian) into a 32-bit big endian register lol

skimothy milkerson
Nov 19, 2006

Luigi Thirty posted:

I spent all afternoon writing a 68k program that takes console input and displays an 8-digit number on the LEDs in easy68k

I will never reproduce

You can always gently caress your computer and cum in it

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

abraham linksys posted:

lol just lol if you don't "use strict" in tyool 2012

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
i'd say that in tyool 2016, lol just lol if you're not using const and let

Sweevo
Nov 8, 2007

i sometimes throw cables away

i mean straight into the bin without spending 10+ years in the box of might-come-in-handy-someday first

im a fucking monster

Luigi Thirty posted:

took me a little while to figure out how to read a 32-bit little endian number (all FAT12 data is little endian) into a 32-bit big endian register lol

code:
ror.w #8,d0
swap d0
ror.w #8,d0

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

jony neuemonic posted:

christ, i clearly need to start using some f#.

keep in mind that very little of the code in that post involves f#'s exclusive features. the syntax is much shorter and sum types are safer than enums, but you could do 95% of that oo-based validation in c# or java (Scott has other tutorial where he does explore the more unique parts of f#)

here's a simpler implementation where the translation to mainstream languages might be more obvious (just add a shitton of useless braces and type declarations everywhere :v:)

code:
[<AutoOpen>]
module Validation = 

    type private 'a Content = Invalid | Valid of 'a

    [<AbstractClass>]
    type 'a Validated (arg) =               
        abstract member Validate : 'a -> bool   
        member private this._content = if this.Validate arg then Invalid else Valid arg
        member this.Value = match this._content with | Invalid -> None | Valid x -> Some x
	member this.IsValid = this.Value.IsSome

type String100(s) = inherit Validated<string>(s) with
    override this.Validate s = s.Length <= 100

type Email(s) = inherit Validated<string>(s) with
    override this.Validate s = 
        let at, dot = s.IndexOf "@", s.LastIndexOf "."
        (at > 0 && dot > at + 1 && dot < s.Length)

tef
May 30, 2004

-> some l-system crap ->

JewKiller 3000 posted:

this is simply a consequence of the fact that sql allows constants of many types to be specified in string literals. see postgres manual section 4.1.2. if those were real columns it would not work, see below:

code:
postgres=# create table t (yos text, pos int);
CREATE TABLE
postgres=# insert into t values ('2', 2);
INSERT 0 1
postgres=# select yos * pos from t;
ERROR:  operator does not exist: text * integer
LINE 1: select yos * pos from t;
                   ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

sometimes it feels like sql is dynamically typed but statically typed for persistent data, it's the best of both worlds :toot:

Soricidus
Oct 21, 2010
freedom-hating statist shill

Wheany posted:

i'd say that in tyool 2016, lol just lol if you're not using const and let

lol just lol if you're writing javascript at all in any yool

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Sweevo posted:

code:

ror.w #8,d0
swap d0
ror.w #8,d0

I did that yeah

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Soricidus posted:

lol just lol if you're writing javascript at all in any yool

well let me just write this greasemonkey script in haskell or erlang or rust

Su-Su-Sudoko
Oct 25, 2007

what stands in the way becomes the way

Wheany posted:

well let me just write this greasemonkey script in haskell or erlang or rust

okay

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

nnoo, i'd still prefer not.

gonadic io
Feb 16, 2011

>>=

Wheany posted:

nnoo, i'd still prefer not.

yeah unfortunately you still have to debug in js

Luigi Thirty
Apr 30, 2006

Emergency confection port.


no no no no no

i expanded my directory enumerator to look for a file named "program.bin" (the number displayer with ORG $1000 changed to ORG $800000), load it into 0x800000 and execute it. i've invented dos.

oh no blimp issue
Feb 23, 2011

Luigi Thirty posted:

no no no no no

i expanded my directory enumerator to look for a file named "program.bin" (the number displayer with ORG $1000 changed to ORG $800000), load it into 0x800000 and execute it. i've invented dos.

write a bootloader and a lovely console in text mode and you've got yourself an os

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Awia posted:

write a bootloader and a lovely console in text mode and you've got yourself an os

that seems like a fun project

can you tell i wish i would have gotten into the cool operating systems classes in college instead of the dumb ones i took :(

oh no blimp issue
Feb 23, 2011

Luigi Thirty posted:

that seems like a fun project

can you tell i wish i would have gotten into the cool operating systems classes in college instead of the dumb ones i took :(

i started trying to write an os once, i got stuck on tooling tbh

my uni os classes consisted of installing dos in a vm, they were mega poo poo

oh no blimp issue
Feb 23, 2011

you'll also have to implement a file system too ofc

oh no blimp issue
Feb 23, 2011

thinking about implementing low level stuff like that gives me a massive programmer erection, but i just can never be bothered when i get round to it

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

me too except for filesystems, which just give me the chills. the idea of me writing a thing that tries to guarantee everyone's data will be on their disk later, in correct form, just sounds like an exercise in hypertension

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Lutha Mahtin posted:

me too except for filesystems, which just give me the chills. the idea of me writing a thing that tries to guarantee everyone's data will be on their disk later, in correct form, just sounds like an exercise in hypertension

i can read precisely 1 cluster from a program on a fat12 disk because i don't know how to read the FAT yet lol

i did write a "console" insofar as it runs my homemade strcmp on a string you input and compares it to a table of strings, throwing an error if nothing matches

Luigi Thirty fucked around with this message at 01:05 on Aug 15, 2016

Series DD Funding
Nov 25, 2014

by exmarx
i work on a distributed filesystem and it's pretty ok. somehow all the threading bugs haven't resulted in data loss yet!

echinopsis
Apr 13, 2004

by Fluffdaddy

Bloody posted:

this is really the thing that makes me most mad every time i look at a thing in python or javascript. p-langs (especially python) are totally fine to read (assuming a non-trash code base) because there's an a priori assertion that the code you're reading is valid, so all these magic function calls are correct, but writing them? literally kill me

i love writing in python

FamDav
Mar 29, 2008

Series DD Funding posted:

i work on a distributed filesystem and it's pretty ok. somehow all the threading bugs haven't resulted in data loss yet!

which one

Bloody
Mar 3, 2013

echinopsis posted:

i love writing in python

how do I add an item to a list? is it add or append? how many items are in it? is it count or length?

multiplied by everything in the language

it's completely unusable to me

a few DRUNK BONERS
Mar 25, 2016

Bloody posted:

how do I add an item to a list? is it add or append? how many items are in it? is it count or length?

multiplied by everything in the language

it's completely unusable to me

wow you must have the memory of a goldfish

how could you possibly use any programming language where you have to remember what methods a list has

Adbot
ADBOT LOVES YOU

hobbesmaster
Jan 28, 2008

who needs memory when ctrl-space works

  • Locked thread