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
comedyblissoption
Mar 15, 2006

A common logger used in .net is NLogger. It seems Good Enough for simple things. You can log at different levels of priority (e.g. logger.Debug, logger.Error, logger.Info) and configure the level of logging in your app configuration. You can build the lazy strings for expensive computations w/ your own wrapper interface trivially if need be.

This is a much better approach than commenting/uncommenting out code for ad hoc logging.

This is also better than having to remember to put if conditionals around all of your logging statements.

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

statically analyze your logging statements to detect side-effects or computations whose results are only consumed by logging statements. I mean seriously are we savages here?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Blinkz0rz posted:

Why couldn't you do
C# code:
logger.debug("The boner hash is {0}", calculateHash(boner));
assuming that calculateHash returns a type that has a string representation?

Does C# execute calculateHash() and then passes the result to logger.debug or does it pass the unexecuted function?

what language, anywhere, doesn't evaluate arguments before passing them to a function

i want to know so i know to avoid it

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

Subjunctive posted:

statically analyze your logging statements to detect side-effects or computations whose results are only consumed by logging statements. I mean seriously are we savages here?

The Something Awful Forums > Discussion > SeriouHardws are / Software Crap > YOSPOS > Terrible programmers





hm

gonadic io
Feb 16, 2011

>>=

Dessert Rose posted:

what language, anywhere, doesn't evaluate arguments before passing them to a function

i want to know so i know to avoid it

langs which are non-strict by default. haskell, agda, and miranda for example. ocaml and f# etc make it very easy to do this too but it's opt-in rather than opt-out.

Shaggar
Apr 26, 2006

Blinkz0rz posted:

Why couldn't you do
C# code:
logger.debug("The boner hash is {0}", calculateHash(boner));
assuming that calculateHash returns a type that has a string representation?

Does C# execute calculateHash() and then passes the result to logger.debug or does it pass the unexecuted function?

its a generic example and it could be a string or something else or you could be doing more than one thing it doesn't really matter. but yeah in c# it would do the calculateHash and pass that to debug.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Dessert Rose posted:

what language, anywhere, doesn't evaluate arguments before passing them to a function

i want to know so i know to avoid it

literally only if logger.debug wraps its arguments in a Func<string> for deferred execution

who the gently caress knows why i dunno i'm a bad programmer

MononcQc
May 29, 2007

gonadic io posted:

langs which are non-strict by default. haskell, agda, and miranda for example. ocaml and f# etc make it very easy to do this too but it's opt-in rather than opt-out.

Add languages with macros-based logging libraries to the list.

Valeyard
Mar 30, 2012


Grimey Drawer

Space Whale posted:

HOLLA HOLLA logger getLogger

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Dessert Rose posted:

what language, anywhere, doesn't evaluate arguments before passing them to a function

i want to know so i know to avoid it

you should pick one and learn it

itll make you a better programmer

Jerry Bindle
May 16, 2003
yeah don't avoid functional languages, they are really good

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I mean assuming you haven't like. quoted it in a list or whatever.

c# doesn't have autoclosure arguments, I guess swift does now tho so at least one curly brace language has it

like I expect that type of shenanigans in f#/haskell

Deacon of Delicious
Aug 20, 2007

I bet the twist ending is Dracula's dick-babies

fleshweasel posted:

bikeshedding megathread

ok, what should go in the OP?

tef
May 30, 2004

-> some l-system crap ->

Dessert Rose posted:

what language, anywhere, doesn't evaluate arguments before passing them to a function

i want to know so i know to avoid it

in tcl you have to put []'s around subexpressions, similarly, bash requires $, or ``. there's the lazy evaluated languages, which build thunks, but there are also the term rewriting languages too. oh and prolog, and datalog treat their arguments as symbolic too.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
yeah and once someone mentioned functional languages i realized lisp macros are technically like that too.

i belong in this thread most days

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Dessert Rose posted:

yeah and once someone mentioned functional languages i realized lisp macros are technically like that too.

i belong in this thread most days

er i thought lisp was a functional language?

Jerry Bindle
May 16, 2003
lisp is a functional language, which basically means that its written in terms of its own data structures. so its not just macros that aren't evaluated before they're passed to function, but any lisp code can be passed before its evaluated

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Dessert Rose posted:

yeah and once someone mentioned functional languages i realized lisp macros are technically like that too.

i belong in this thread most days

tbf i wasn't taking about a functional language i was just being dumb

leftist heap
Feb 28, 2013

Fun Shoe

Barnyard Protein posted:

lisp is a functional language, which basically means that its written in terms of its own data structures. so its not just macros that aren't evaluated before they're passed to function, but any lisp code can be passed before its evaluated

source yr quotes

brap
Aug 23, 2004

Grimey Drawer
swift has a thing called @autoclosure where an argument expression is automatically converted to a function by the compiler.

the ?? operator uses it

foo = foo ?? getDefault()

?? can be executed without evaluating the second expression for the second argument. getDefault() only needs to be evaluated if foo is nil.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

tef posted:

in tcl you have to

oh jesus you just gave me a seizure

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Barnyard Protein posted:

lisp is a functional language, which basically means that its written in terms of its own data structures. so its not just macros that aren't evaluated before they're passed to function, but any lisp code can be passed before its evaluated

you have to quote a list to pass it to a function unevaluated, whereas a macro always receives its arguments unevaluated (because macros operate on and evaluate to code themselves)

also, you can't pass a macro to a function, because a macro expands at compile time where a function evaluates at runtime

fleshweasel posted:

swift has a thing called @autoclosure where an argument expression is automatically converted to a function by the compiler.

the ?? operator uses it

foo = foo ?? getDefault()

?? can be executed without evaluating the second expression for the second argument. getDefault() only needs to be evaluated if foo is nil.

yeah it's the only non-functional language i know of that has a feature like that

gonadic io
Feb 16, 2011

>>=
Functional doesn't mean non-strict/lazy. F# and OCaml are strict for example. Haskell is functional and non-strict but it's hardly representative.

On a side note, SPJ has said that if Haskell had been strict, he probably wouldn't have been able to resist putting in implicit side-effects the way OCaml has.

gonadic io
Feb 16, 2011

>>=
Mind you too, almost all langs have && and || evaluate their second argument lazily too.

MeruFM
Jul 27, 2010

gonadic io posted:

Mind you too, almost all langs have && and || evaluate their second argument lazily too.

why would you do || lazily???
Not so stealthy edit

MeruFM fucked around with this message at 08:52 on Mar 1, 2015

MeruFM
Jul 27, 2010
stealth edit because i belong in this thread

gonadic io
Feb 16, 2011

>>=

MeruFM posted:

why would you do || lazily???

True || _ = True

MeruFM
Jul 27, 2010
yeah i realized that as I went through it again in my head for the 20th time

leftist heap
Feb 28, 2013

Fun Shoe
everyone who posts in this thread proves they belong here eventually

gonadic io
Feb 16, 2011

>>=

rrrrrrrrrrrt posted:

everyone belongs here

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

ya we've definitely had this discussion before

we're all terrible

every last one of us

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?

fleshweasel posted:

bikeshedding megathread

dehumanize yourself and face to bikeshed

Valeyard
Mar 30, 2012


Grimey Drawer

Notorious b.s.d.
Jan 25, 2003

by Reene

eschaton posted:

dehumanize yourself and face to bikeshed

comedyblissoption
Mar 15, 2006

eschaton posted:

dehumanize yourself and face to bikeshed

Bloody
Mar 3, 2013

personally i think it should be dehumanize  yourself  and  face  to  bikeshed

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Bloody posted:

personally i think it should be dehumanize  yourself  and  face  to  bikeshed

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

No assholes

leftist heap
Feb 28, 2013

Fun Shoe
dehumanise

Adbot
ADBOT LOVES YOU

bucketmouse
Aug 16, 2004

we con-trol the ho-ri-zon-tal
we con-trol the verrr-ti-cal

that's the spirit

  • Locked thread