Show newer

@vaporeon_ what those were originally linked to i've lost sadly, mistake on my part fur not removing the links

@wallhackio @vaporeon_

Cling is an interactive C++ interpreter, built on the top of LLVM and Clang libraries. Its advantages over the standard interpreters

interpreters?? plural??? what else is there beside CINT????

@wallhackio @vaporeon_ Cling is also free software, dual licensed under a bespoke 3 clause BSD license and the LGPL

@wallhackio @vaporeon_ i was SO confused when he was explaining it to me

:aescling_0908:​ since when did C++ have a REPL???

:clodsire_head:‍:clodsire_tail: what’s a REPL?

:aescling_0908:​ ah,

@vaporeon_ the names are conventional but the only impurrtant part is the * and **. a * arg is basically variadic arguments:

def fun(a, *args):
...

takes one required argument and any number of optional arguments, available in fun as a list bound to args

understanding the ** argument requires furst understanding the notion of "keyword" arguments. it is allowed to invoke the above function as fun(a=1). if it took mulitple arguments, i could supply keyword arguments in arbitrary order:

def fun2(a, b):
return b

fun2(1, 2) # 2
fun2(b=1, a=2) # 1

normally, it is a TypeError to supply an unexpected keyword argument to a function, but if there is a ** argument to the function, it is bound to a dict available the ** argument`s name:

def fun(**kwargs)
return kwargs

fun(a=2, b=3) # {'a': 2, 'b': 3}

an extremely common pattern is to write a thin wrapper around another existing function that takes keyword arguments. python has convenient syntax for inserting keyword arguments into a function call from a dict:

import requests

BASE_URI = # ...

def get(path, **kwargs):
# the HTTP methods in the requests library take a large number of optional keyword arguments
return requests.get(f"{BASE_URI}{path}", **kwargs)

auth_headers = # ...
print(get("/api/records", headers=auth_headers).json())
Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.