Old Thread >>51294963
Whatcha working on, /dpt/?
Also, whats your favorite data type?
first for java
second for java sucks
I'm transforming SQL code into pl/sql procedures.
Vim really helps with macros and regex.
My favourite data type... either dictionaries or lists. I can't really decide.
>>51298891
Wow, I was struggling to get what OP's pic was until I read "give me some pointers"
10/10
>>51298891
currently programming a GUI interface using Visual Basic
>favorite data type
Boolean (only Java users will get this)
fifth for java sucks.
C master race.
Go loses the race.
>>51298891
That joke wasn't funny the first time.
why the fuck /g/ do not have id's?
>>51298922
>GUI interface
>Visual Basic
Why not C#?
Also
>GUI interface
>Graphical User Interface interface
I'm writing a Gameboy emulator in D and a Lisp interpreter in Go. How many meme points do I get?
And bytes are the best data type desu
>>51298945
Because we legun. Expect me.
>>51298945
It's too slow.
>>51298959
what the fuck is legun mean dude? also expect what?
>>51298945
Why would we?
>>51298959
omg u don't even know our motto
it's expecto patronum
>>51298891
Nullable Boolean.
Come at me.
>>51299001
I prefer to call it the gender boolean.
>male
>female
>qt programmer
>>51298891
I took over working on a new site for a company that deals heavily with aircraft specifications. They have an extensive database with all the specs which is the core of their business. Their old site was run off of joomla with the specifications database hookup integrated. They didn't like Joomla, so the new site I am working on is a custom CMS through codeigniter. The Indian chick who was working on the site before me was combining the cms user tables with the aircraft specification tables. Is this a good idea, or should I separate the two and use codeigniter to access the two tables through model db connection calls?
>>51298891
LMFAO at that pic. That OP is making fun of people in Programming 101 class, right?
>>51298966
you mean /g/ fast for id shit? too heavy for server to process?
>>51298986
to understand the samefags
>>51299018
I wonder if SJWs legitimately think booleans are sexist.
>>51299024
>The Indian chick who was working on the site before me was combining the cms user tables with the aircraft specification tables.
Where?
In the CMS database or what?
>>51299027
/g/ isn't populated by shitheads like /b/ is
even /v/ doesn't have forced IDs and it runs almost as fast.
>>51299027
>you mean /g/ fast for id shit? too heavy for server to process?
Threads last longer, which means samefag would remain samefag for 4 hours, vs 15 minutes on something like /pol/.
>>51297230
>>51297276
>>51297292
arguments in Go ;)
https://golang.org/ref/spec#Passing_arguments_to_..._parameters
all of you need to fuck off
>>51299057
She started a new database and was combining the 2. That approach seemed pretty stupid to me. The specs tables won't change so she probably should have just been adding the new CMS tables to the one live specs database if that was the approach that she was going to take. It seems like a easier but sloppier approach to me. My initial reaction is to ditch that plan and just have 2 defined database tables in codeigniter, though I see no real reason why both types of tables can't just be in one DB.
>>51299068
>>51299081
i see, its pointless.
>>51299093
>C#
Am I missing something, or did your link just explain how to do pic related in Go?
Just reverse engineering youtube.
>>51299272
>reverse engineering
>html
>>51299294
Are you retarded?
Which freelance skill out of these isn't incredibly hard, and makes OK money?
>WinAPI programming
>Linux distro development
>Linux kernel module development
>>51299178
>She started a new database and was combining the 2
As in, putting those two tables as two new tables in that database?
That's fine, it's part of the advantage of having something like a data warehouse. You only have to deal with one version of the truth, instead of connecting to two separate databases.
Using multiple databases on the same display can cause issues in some BI tools, but as far as the website is concerned, it's kind of a moot point.
>>51299319
>html
>programming
>>51299345
>MUH DATA STRUCTURES
>MUH ALLLGGGOOORRRRITTHMMMSSSSS
javascript programmer here
how goes it?
>>51299334
>makes OK money
WinAPI programming desu. You try to sell a program under Linux and neckbeards start popping up calling your product literal cancer.
License for this thread:Copyright (c) 2015, Anonymous
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>51299373
>javascript
>programmer
pick one
>>51299369
lel im the guy that always says that
sup bro
>muh binary trees
>muh allocated memories
>>51299387
javascript is programming. It's just a dynamic language. But it's still programming
>>51299224
yeah, nm, there are no tuples in Go
>>51299272
wat. doesn't youtube support JS map files?
>>51299405
sureeeee
>>51299391
At work, tired. 2 hours to go. Just been doing blow in the bathroom most of the day. You?
>muh UDP
>muh gentoo
>>51299405
>javascript fags thinking they're programmers.
Listen. It's called JavaSCRIPT for a reason. You're just a scripter.
What the fuck is a Mutex and what do I do with it?
>>51299450
Texan cows.
You tip them when they go to sleep. They spaz out and are all "muuuuuuu".
>>51299339
I meant to databases instead of 2 dB tables. The spec and cms tables don't overlap at all. The spec tables are just specs and the cms tables are user permissions and such. With Joomla there were obviously 2 different databases, but now that the cms is custom all the tables can be in one database. I just don't know if there is any logical reasons to keep the cms tables in a different database than the spec tables.
>>51299455
I live in Texas, though, and I haven't heard of these.
Either way, is it like a "Speaking Pillow"?
Like, your at the divorce councilor and you can only talk if you're holding the pillow.
So like, the mutex is the speaking pillow, except, you put your mouth up to it and speak your data directly into the warm folds of the pillow.
>>51299482
I've never been to a divorce councilor. Only to jail for domestic assault, and those guys don't care if you're bitin-- holding a pillow.
>>51299482
That's...not a bad analogy for a mutex.
hello guys,
i have the following problem:
i must replace single quotes with double quotes, except the single quotes are written between double quotes
currently i'm doing it with python without the exception
mystring=re.sub("'",'"',mystring)
example:
> {'hello': 'world'}
{"hello": "world"}
> {'place': "I'm here"}
{"place": "I'm here"}
someone have an idea?
>>51299458
Well, you *could* have it all in one DB, but it might be better to let the CMS app have its own DB for compartmentalization purposes.
>>51299540
What the fuck.
THESE are the Indians coming to steal our jobs?
>>51299585
Yup. They're completely retarded.
Never outsource.
It will always cost you more to rewrite their feces-signed code than if you had just developed it inhouse.
>>51299585
dey
yuk
der
JERRRRRRRRRRRRR
>>51299376
What if you don't plan selling your stuff, but want to just freelance and program for someone?
Isn't Linux distro development popular and well-paid on freelance sites now?
>>51299450
I'm guessing mutual exclusion.
>>51299676
>>51299676
>>51299676
Posted in dead thread.
>>51299450
It's used from multithreading.
http://lmgtfy.com/?q=mutex
>>51299450
It works a bit like this
https://www.youtube.com/watch?v=2F89dl26wq8
>>51299690
Visual Studio
>>51299690
I just wrote a little bash script to create $1.c with codeeval settings so I don't need to type it every time. Could do that.
>>51299615
Well that's a bit different. I think what you're talking about is System Administration. If you're planning on getting a job in a Linux environment, sure, pick the Linux route. But your choices for software development is either to go work at red hat for linux (which they barely do), or learn the WinAPI
>>51298891
>16-bit addresses
>>51299723
kek
>>51299803
>not realizing that 0x6700 is literally the same as 0x0000000000006700
>>51299690
Try JetBrains products.
>>51299803
>4*16 = 16
>>51298891
I'm bored and want to contribute to some opensource project for fun and to add to my public github profile. I know C, C++, Java, Ruby, and PHP.
What bugs or features do you want fixed or added in your favorite program or os?
>>51299851
>impying a bit is a hexadecimal digit
>>51299853
I'd really like #lang C for racket. Thx.
>>51299853
You should rewrite the Linux kernel in C#
>>51299556
That's what I am thinking. Thankfully she hadn't gotten very far, but this is why I don't like taking over projects. It was pretty obvious from her sloppy code that she didn't really know what she was doing. I'm glad her husband lost his green card so that they could get deported.
>>51299864
>implying I implied that
>>51299446
A "scripting" language is a programming language wherein the source code is the final program, rather than being ahead of time compiled into machine code or bytecode. All scripters are programmers.
It's always encouraging when nobody responds to your code in /dpt/ because chances are nothing is glaringly wrong with it, but it also kinda sucks
>>51299915
Or it was just so embarrassingly bad that nobody wanted to respond
>>51299540
not a goddamn regular language you fucking fuck faggot fuck
>>51299932
There will always be someone on /g/ to shit all over your code if it's really embarrassingly bad
>>51299093
but we were discussing tuples you mong
>gotards and reading comprehension
>>51299853
Fix systemd
>>51299853
Would you be willing to add some bugs to something I'm working on?
>>51299391
>muh red black trees
>muh djiikstra
Trying to create an old-fashioned web app where the pages are rendered on the server and it's mainly about handling forms. For now I'm not going to write a single line of client-side JS and bask in the glory of how web is supposed to work.
My back-end is JS though :-)
>>51299387
>>51299446
javascript is turing complete retards
Learning D
>>51299902
apart from shell programs like bash then there's basically no "scripting languages" left
well I guess picolisp
maybe forth depending on your autism levels
fucking captcha fucked up my chance to get quints I TYPED IT CORRECTLY YOU SHIT
>>51300006
>maybe forth depending on your autism levels
They're high anon. Really high.
What are some good Python resources? I know the language but don't feel like I completely grok some of its more obscure syntax.
How to transfer multiple types of data between Classes in Java using only one method?
>>51299978
Link the repo?
>>51300006
>there's basically no "scripting languages" left
JavaScript
Python
C#
F#
PHP
Ruby
SQL
>>51299902
even little kids can write scripts because its so easy.
>>51300046
create a new class while holds each of the data types you want to return, then make your method return that.
>>51300066
was kidding but post throwaway email
>>51300006
Consider the definition I just gave you for a scripting language, and tell me you really think that only Bash and Picolisp will fit the definition. Protip: Ruby, Python, and Perl all fit the bill.
>>51300091
Just because it's easy doesn't mean it's not programming.
>>51300137
I don't know about ruby and perl because they're shit but python has a bytecode representation. Most languages do today.
>>51300189
>python has a bytecode representation
That doesn't stop it from being a scripting language.
>>51300137
>Consider the definition I just gave you for a scripting language, and tell me you really think that only Bash and Picolisp will fit the definition. Protip: Ruby, Python, and Perl all fit the bill.
Your definition unfortunately isn't the word of god.
"Scripting languages" traditionally means languages that are simple (hence interpreted) and used for small automation of tasks. Hence a "script" is a small program, usually a utility.
However, lately languages like Python and Ruby have been used for full scale applications (usually web servers) rather than just small "scripts". (Perl on the other hand...?)
>>51299897
topkek
Good to hear.
>>51299902
Those are called interpreted languages, skiddie.
>>51300240
>interpreted languages
Interpreted programming languages, yes.
https://en.wikipedia.org/wiki/Scripting_language
>>51300272
The key point about scripting languages is
>Typically scripting languages are intended to be very fast to learn and write in, either as short source code files or interactively in a read–eval–print loop (REPL, language shell).
>This generally implies relatively simple syntax and semantics; typically a "script" (code written in the scripting language) is executed from start to finish, as a "script", with no explicit entry point.
>For example, it is uncommon to use Java as a scripting language because of its lengthy syntax and rules about which classes exist in which files, and it is not directly possible to execute Java interactively, because source files can only contain definitions that must be invoked externally by a host application or application launcher
>In contrast, in Python it is possible to define some functions in a single file, or to avoid functions altogether and write in an imperative programming style, or even to use it interactively.
Making an animal guessing game in python for fun
>>51300203
>That doesn't stop it from being a scripting language.
it does according to the definition that the tripfag gave
>>51300297
His definition was incomplete but not completely incorrect.
I'm not arguing the semantics of scripting vs interpreted languages, just that they're both still considered to be programming languages.
>>51300297
The key point of "scripting language" is to use it as a term of derision. It's never seriously used in any other way since it really has no meaning.
>>51300371
It's a good term though, it describes the kind of language that you'd write a quick file renamer or website scraper in
python and JS are compiled languages
>>51300003
don't you love the D?
>>51300381
>my interpretation of the term is good though so everyone should just listen to me
'kay
>>51300406
>python and JS are compiled languages
No they're not, compiled language implies that they're compiled directly into native machine code. They're "compiled" into bytecode, which is then interpreted (and possibly JIT compiled) by a virtual machine process
>>51300406
I love the D, it makes mine super hard
>>51300436
>No they're not, compiled language implies that they're compiled directly into native machine code
no it doesn't
>>51300455
>https://en.wikipedia.org/wiki/Compiled_language
>The term is somewhat vague; in principle any language can be implemented with a compiler or with an interpreter. A combination of both solutions is also common: a compiler can translate the source code into some intermediate form (often called bytecode), which is then passed to an interpreter which executes it.
OK yes in some sense Python and JS are compiled, but the end step is an interpreter which is required for actual execution. I'd call that interpreted
>>51300436
So you're saying that Java isn't compiled, even though you clearly have to run a compiler program on your source code
>>51300497
Ok fuck you've got me there. Clearly it's less black and white than one would think
c# has 1k page instruction book to read
c only 250 page
still c real hard to understand
Wtf, what is this shit?
sup bros
just finished my first codeacademy course and I'm bored already
what do?
>>51300525
MUH. DATA STREUFCKRTERESS
>>51300421
just saying that it's not always a negative term, and some people use it in a positive context. you're getting pretty up in arms anon
>>51300525
to understand C, you need to understand hardware/OS features, too, not just C
>>51300556
C is easy, any idiot can do it.#include <iostream>
double main (volatile long long int dataGoesHere) {
printf("Hi, World@\t");
return;
}
>>51300189
When you run a python program, say viapython foo.py
Is the input file text or binary? In nearly all cases, it is text. That it is then translated to bytecode at runtime for better performance is irrelevant. The point is that at the program start, what is being run is the source.
By the way, Ruby and Perl are the same in this respect. What is distributed is text. What is run is text, but the interpreter compiles the text and then runs it, rather than having one program to compile it ahead of time, and then another to JIT compile it to native code.
>get web dev internship
>its just fixing bugs for a web app that has so many nasty lines of code my eyes hurt
what have i gotten myself into /g/?
>>51300590
you are not belong to here grey gandalf, go to web developer thread
>>51300488
>the term is somewhat vague
stopped reading right there since it proves the point
also
>wikipedia
>>51300615
but i thought we concluded javascript is programming?
>>51300575
>C is easy, any idiot can do it.
>#include <iostream>
speaking about idiots...
how to code crypter?
>>51300622
*gives you a good ol' pat on the bum and sends you off to school*
>>51300575
I can't tell if you're actually retarded or just pretending
>>51300621
we are not, if you thought we are then you talked with someone else. i said
>programmer
>javascript
pick one.
>>51300651
Why? Is it because I forgotusing namespace ptsd;
?
>>51300302
>python2
>break
>global
>>51300660
see >>51299387
this is now a meta-joke, meta-meme thread
>>51300691
yea that is me, you mad scripter ? you should talk like, i dont care what you think, im a programmer. or post your total income to convince us ^^
>>51300581
>That it is then translated to bytecode at runtime for better performance is irrelevant. The point is that at the program start, what is being run is the source.
The differences you are willing to ignore are larger than the similarities you wish to accept.
>>51300720
why would I be mad? I can code all my programs in bash and get all the benefit of a C program
>>51300660
Nice bait.
>>51300763
lol
>>51300792
how can it be a bait, if its my real opinion?
>>51300763
kek, scripter is funny guy though
>>51300837
Define programming then.
>Argument over semantics
I'll be out for awhile, call me when it's over
>>51300847
#define programming
>>51300870
#define define
>>51300865
why don't you start a shitstorm over syntax instead faggot coward bitch
>>51300847
if (programming != javascript)
{
System.out.println("Congrats!");
}
else
System.out.println("Not a real programmer fampai");
>tfw whenever i talk to programmers in real life im too embarrassed to ask if they post on /g/ too
>>51300923
Nice argument, faggot.
>>51300741
Tell me what it is I am overlooking then. I provided a definition for a scripting language that concerns not the structure of the programs that utilize it, but the means by which programmers utilize their programs. If the input file to python is a source file, and the output is not necessarily either an error or a bytecode interpretation of that source file, then what is being run is a script. Anything else is an optimization.
>Also, what's your favorite data type?
the abstract representation of another data type
Why should I use one or the other convention?mVariable;this.variable;
>>51300923
isnt that backwards?
>>51300983
I think you meanthis->variable;
>>51300581$ nuitka foo.py
$ foo.exeW the
>>51300999
Checked, but why should I use it overmVariable?
>>51300763
Enjoy your fork() overhead.
>>51298922
Code a GUI interface to trace his IP!
>>51301007
>foo.exeW the
typo, blaming my phone's autocorrect
>>51298925
I like both :3
>>51301029
I prefer mVariable (or m_variable desu senpai), just pointing out that this is a pointer.
As for why, becausex.variable()is less shit thanx.getVariable()and using a prefix means the names won't collide.
>>51301029
if it's ambiguousstruct muhOOP {
int var;
int muh_function(int var) {
return var + this->var;
}
}
Trying to debug a vim plugin that defines syntax highlighting for homoglyphs.
For whatever reason when ft is mail or markdown it highlight [kK] as well on top of the homoglyphs, it works properly when the ft is a programming language.
Confusion intensifies.
>>51300622
>>51300651
>>>/reddit/
>>51301092
ignore this I'm hi xD
>>51298891
Learning frameworks. Not fun.
>>51300954
There is no useful distinction. You already accepted "bytecode" as AOT then basically you're saying that C, C++, etc., are also "scripting" languages because the "compilers" are really compiling to an intermediate representation for an internal virtual machine. The rest is just "optimization." But this is a ridiculous viewpoint to try to maintain.
As AOT and JIT merge more and more the distinction between "scripting language" and other languages vanish. This is even more true for languages that are normally interpreted (by a virtual machine) but also have native-code compilation (e.g. java and ocaml, arguably R4RS scheme with stalin), and you have the perversion that native-code languages like lisp run on a lisp machine (or scheme run on the demo chip MIT made years ago) are somehow both a compiled language and a scripting language.
The distinction is just a matter of where someone wants to be derogatory for internet dicksizing and is of no practical value.
can someone explain to me why the hell this is allowed to compile?int main(void) {
int x = x;
}
>>51301196
No idea
Can you?
>>51301196
what are some reasons it wouldn't be allowed to compile?
>>51301196
Declaration and assignment at the same time is just sugar.int main(void) {
int x;
x = x;
}
>>51301239
>>51301278
i understand this but i'm surprised the sugar syntax allows it since it's a possible typo and has no purpose
if it has a purpose well, that's why i'm asking "why is this allowed"
When is a problem solvable?
I've found that problems are solvable when they are computable.
Something is computable when it can be represented by an algorithm.
For something to be an algorithm, it needs to consist of small and clear steps and also have a solution for every solvable problem.
Isn't this recursive?
>>51301323
*For every solvable solution to the problem
>>51301316
Exceptions to a rule -> clunky
This being the cause of a significant bug (i.e. one that alters the functioning of your program) -> very low
Analysis of +clunky VS -buggy = not worth it
>>51301196
Compiler warnings would probably warn you about that, shame you don't enable them.
>mfw node tutorial on codeschool now
>>51301426
i use -Wall, that's not the point
>mfw there's a growing functional programing movement at work
>mfw we just added sbt (scala) to our builds
>mfw I will be leading a three day "Write yourself a Lisp" seminar
>mfw getting paid go write Haskell
Life's good bros
>>51301426
-Wall -pedantic doesn't say anything.
>>51298891
>16 bit
>>51298891
Snake in Java
Boolean master race
its very cool to be able to program but have no fucking use for the skill
>>51301657
get a job?
I don't use boost or STL.
What are C++ templates? How are they handled by llvm and stuff?
Are they a bad thing? What's the diff between C++ and a define in C?
What does I need to know about C++ templates before I use STL?
Writing a generic packet parser in Python.
Rate my code, /dpt/def mkpacket(name, fields):
class P(object):
_fields = fields
def __init__(self, **kwargs):
for k, v in kwargs.iteritems():
if k not in [f[0] for f in self._fields]:
raise KeyError
setattr(self, k, v)
def encode(self):
data = ''
for f, t in P._fields:
data += t.encode(getattr(self, f))
return data
@staticmethod
def decode(data):
consumed = 0
pkt = P()
for f, t in P._fields:
value, count = t.decode(data[consumed:])
consumed += count
setattr(pkt, f, value)
return pkt
P.__name__ = name
def getter(varname):
def _get(self):
return getattr(self, varname)
return _get
def setter(varname):
def _set(self, value):
setattr(self, varname, value)
return _set
for fname, field in fields:
vname = '_' + fname
setattr(P, vname, None)
setattr(P, fname, property(getter(vname), setter(vname)))
return P
EthernetPacket = mkpacket('EthernetPacket', [
('dst', MACAddressField),
('src', MACAddressField),
('ethertype', IntegerField(2)),
('payload', PacketField),
])
>>51301682
yea but where?
>>51301705
Pretty much anywhere.
>>51301688
I won't rate so to speak but we can talk about it
Why a class inside a method? How do you plan on testing it?
How do you plan on being able to use the staticmethod decode if you can't access it?
Instead of using a getter and a setter, consider using an abstract base class for it:
https://docs.python.org/3/library/collections.abc.html
Also, it'd be helpful to see how your class is used in practice. How EthernetPacket would be used in practice.
It seems like what you're creating may be better suited for meta classes - however, I wouldn't recommend it. Metaclassing out stuff like that isn't as helpful, it's probably better off to go for readability.
If you need me to be more specific I can.
>>51301687
Templates in C++ allow you to write routines for generic data types. Let's say you write a hashing algorithm that takes in a string. If you want to apply that algorithm that takes in a class of Truck you're going to have to write a new routine that has the same algorithm but it deals with onlyTruck[/codes]s. You might be able to see that it's easy to get all sorts of redundant code that has the exact same algorithm applied to different data types. This is where C++ templates come in. Templates in C++ allows you to write routines that take in a generic type and then manipulate that generic type (as long as that kind of processing is logically sensible).
>>51301688
>>51301752
BTW, I'd rather see you creating classes for this.
Consider creating a BasePacket class, then a BaseField class, and abstract those out.
BaseField and BasePacket can extend that ABC collection I linked to.
That will make the code a lot more readable, testable and maintainable.
>>51301687
C++ templates are essentially a formalization of the macro system used in C. while they are still "text substitution," the substitutions are all formal types, and the templates are type variables
in 95% of cases this is used for type-generic programming. for example, the dynamic array class, vector, is really vector<Type>. when you declare a vector, you write vector<int> or vector<Waffle> or w/e the fuck, and the compiler does type substitution and generates code for vector<Waffle>. a more exotic case is tuple<...Types>, e.g. tuple<int,int,double>. this is all you need to know to use 95% of the standard library
templates can be used for fairly advanced library implementations. for example, you can template a functor (a type that implements operator() ) to pass templated code. this is what std::sort<Comparator> does, and is why C++ sort outperforms C's qsort (because the comparator is passed by substitution instead of a void pointer). the most advanced kind of template programming is metaprogramming, which you really shouldn't tackle if you don't know C++ well
>>51301784
If I'm using these template systems, will I get autocomplete with stuff like clang_complete in vim still?
What about type safety?
What about debugging?
What about performance?
>>51301784
>>51301773
>>51301687
Link me to some PDF's and tutorials on the basics of templating?
Is there such a thing as STL/Boost for C?
>>51301784
a good example of simple metaprogramming is std::enable_if<bool,type>. if bool == true, then enable_if<true,type>::value == type. if bool == false, then enable_if<false,type>::value does not exist. so this lets you write code that tests for a compile-time condition, and only works if the condition is true (it's a little more complicated than that, but that's the idea)
>>51301705
its 2015 theres tech companies literally everywhere
>>51300615
hukd on fonikz wurkd fur mee
>>51301810
C doesn't deal with templates so there is no standard template library for C. It's not idiomatic to do generic data programming in C so it's best to avoid this idiom when writing your C programs.
I've been working for months on porting Space Invaders to my toaster oven in PHP. Almost done. Have a conference call with Google scheduled and I'm expecting an buyout offer.
>>51301795
template programming is very standard and idk why any autocomplete would ignore it
it's type safe
it's notoriously hard to debug, except in simple generic type cases, which are frankly most cases. do not do anything more than generic types (e.g. vector<int>) unless you are very familiar with C++
performance is excellent at runtime (that's the whole point, to generate great code using static compile-time code generation instead of runtime type dispatch). however, performance is notoriously terrible at compile time
>>51301810
generic types in C are notoriously hard. you can use macro-generated code (e.g. #DECLARE_VECTOR(TYPE)) or unions for runtime polymorphism. both options suck desu
template programming beyond the simplest case is hard. the simplest case is easy, and is just:template <typename Type>
class MyClass {
Type value;
...
Type is just a variable type
>>51301726
>>51301827
So why haven't I been hired yet?
>>51301894
cuz u dum as hellllllll son
>>51298946
Twas a spoof, adnan.
How could I make it that, let's say I type dog in the textbox, it would take the first result of a google image search and show it in my picturebox?
>>51301977
I'm sure thats the case
You guys literally have no proof that there are programming jobs, please post evidence that there are jobs before making these claims.
IT BEGINSnamespace doric {
template <typename ...Ts>
class column_vector : {
public:
using wide_reference = std::tuple<Ts&...>;
private:
std::tuple<std::vector<Ts>...> columns_;
>>51302065
The trolling is strong with this one.
It sure is a lot of fun programming and not being paid to do it.
>>51302072
>no proof that there are programming jobs
lol wut
praise based k&rmain(argc, argv)
char **argv;
{
extern puts();
puts("Hello, world!");
}
why is python so shit
there's always some gotcha that I have to work around
I often see a 'swap' method in the pseudocode of certain sorting algorithms. Is there a built-in method for swap in c# or do you have to define it yourself?
>>51301841
>It's not idiomatic to do generic data programming in C so it's best to avoid this idiom when writing your C programs.
Good thing generics are never necessary. :^)
>>51301752
>>51301782
Abstract base classes are where I came from, but it gave a lot of boilerplate code when I had to implement getters and setters for properties all the time.
Classes like the ones in SQLAlchemy are what I aimed for, but I couldn't get the properties to work that way.
It would have been better if I could make a class like this:class EthernetPacket(LinkLayerPacket):
structure = [
('dst', MACAddressField),
('src', MACAddressField),
('ethertype', IntegerField(2)),
('payload', PacketField),
]
The order is important, so that's why I used a list.
If I make the properties and variables without this reference, I have to write an encode and a decode function for each protocol.
When it comes to using these classes, they will be used in a receive loop, egwhile True:
data = self.sock.recv(self.mtu)
pkt = EthernetPacket.decode(data)
if self.promiscuous or pkt.dst in self.addresses
rxqueue.put(pkt)
I'm still looking into descriptors (__get__ and __set__), because when the *Fields inherit that from the Field superclass.
That would pretty much give the behavior I want.
I didn't encounter any problems testing it though.
>>51302248
I mean swapping of elements in an array
>>51302065
Doesn't Jewgle have an API?
>>51302248
>Is there a built-in method for swap in c# or do you have to define it yourself?
There isn't one, as far as I know (and MSDN seems to confirm that.) You could implement it fairly simply as an extension method.
So apparently python has type hinting now?def greet(name: str) -> str:
return "Hello, " + name
def sum(lst: List[int]) -> int:
cunt = 0
for i in lst:
cunt += i
return cunt
Still completely worthless and a nonthing.
Hey /dpt/ I'm trying to read multiple txt files with Java scanner. The issue I'm having is that Scanner requies a new scanner object everytime I need to read a different file. Isn't it highly inefficient to have 900 scanner objects in memory if I have 900 txt files? I'm trying to read 2 txt file at a time, compare, delete from main memory then load in another 2 txt file, repeat. I know I can use scanner.close() but does it also require something to flush the input stream like BufferedReader?
>>51302249
There are situations when it's useful to have algorithms that work on generic data. During system analysis, if I strongly suspect that I will need to be working with generic data in a "significant" manner, I would reconsider my usage of the C language to solve the problem. Other languages that I'd consider would include Scheme, C++ and Python.
>>51302284
I believe there is one but desu I'm a total noob and don't really know what I would do with an API
>>51302333
As denoted by the ':^)' interpretation hint, I was joking.
Glad you're staying sharp, though.
>>51295342
>that's redundant; also float is not guaranteed to be 32 bits nor double to be 64 bits
yes they are (pic)
https://en.wikipedia.org/wiki/Single-precision_floating-point_format
https://en.wikipedia.org/wiki/Double-precision_floating-point_format
import qualified Data.Sequence as S
data Card = CA|C2|C3|C4|C5|C6|C7|C8|C9|C10|CJ|CQ|CK deriving (Show,Eq)
pairsWith :: Card -> Maybe Card
pairsWith CA = Just C10
pairsWith C2 = Just C9
pairsWith C3 = Just C8
pairsWith C4 = Just C7
pairsWith C5 = Just C6
pairsWith C6 = Just C5
pairsWith C7 = Just C4
pairsWith C8 = Just C3
pairsWith C9 = Just C2
pairsWith C10 = Just CA
pairsWith _ = Nothing
prop_mutualPairs :: Bool
prop_mutualPairs = all prop_mutualPairs' [CA,C2,C3,C4,C5,C6,C7,C8,C9,C10,CJ,CQ,CK]
prop_mutualPairs' :: Card -> Bool
prop_mutualPairs' c = case pairsWith c of
Just d -> Just c == pairsWith d
Nothing -> c `elem` [CJ,CQ,CK]
getTriple :: S.Seq Card -> Maybe (Int,Int,Int)
getTriple xs = do
let is = S.findIndicesL (`elem` [CJ,CQ,CK]) xs
(i1,is') <- unconsMay is
(i2,is'') <- unconsMay is'
(i3,_) <- unconsMay is''
return (i1,i2,i3)
getPair :: S.Seq Card -> Maybe (Int,Int)
getPair cs = case getFirstPair cs of
Just i -> Just (0,i)
Nothing -> do
(_,xs) <- seqUnconsMay cs
(i1,i2) <- getPair xs
return (i1+1,i2+1)
possibleMove :: S.Seq Card -> Maybe [Int]
possibleMove cs = case getTriple cs of
Just (i1,i2,i3) -> Just [i1,i2,i3]
Nothing -> case getPair cs of
Just (i1,i2) -> Just [i1,i2]
Nothing -> Nothing
makeMove :: [Int] -> ([Card], S.Seq Card) -> ([Card], S.Seq Card)
makeMove [] x = x
makeMove _ ([],x) = ([],x)
makeMove (i:is) (c:cs, x) = makeMove is (cs, S.update i c x)
solve :: [Card] -> S.Seq Card -> Maybe (S.Seq Card)
solve [] x = Just x
solve (c:cs) x | S.length x < 9 = solve cs (x S.|> c)
solve cs x = do
move <- possibleMove x
let (cs', x') = makeMove move (cs, x)
solve cs' x'
getFirstPair :: S.Seq Card -> Maybe Int
getFirstPair cs = do
(x,xs) <- seqUnconsMay cs
y <- pairsWith x
S.elemIndexL y cs
(Too long to fit definitions of unconsMay and seqUnconsMay. They do the obvious.)
Generally speaking how would one handle an app/game that uses hundreds of textures?
Read in a file containing all the info then store them in a container?
How am I supposed to know exactly which one I need to work with?
>>51302176
You have to become gotcha.
#include <iostream>
using namespace std;
int main()
{
int month, year, day;
//Explanation of what inputs are valid
cout << "Please no negative numbers. Month range: 1-12 and day range: 1-30 \n";
//the day of a month
cout << "Enter a day in numeric form \n";
cin >> day;
//The month of the year
cout << "Enter a month in numeric form \n";
cin >> month;
//The last two digits of the year
cout << "Enter the last two digits of the year \n";
cin >> year;
//Choices as to month*year equals or does not equal year.
if ((month <= 0 || month > 12 ) || (day <= 0 || day >= 13))
{
cout << "Invalid entry. \n";
}
else if (year != (month*day))
{
cout << "The date is not magic \n";
}
else if (year = (month*day))
{
cout << "The date is magic \n";
}
return 0;
}
Rate code for someone who is taking a c++ introductory course.
>mfw Java has infected my brain to the point where it's a natural tendency to NameEverythingLikeAJavaEnterpriseProgrammmer
looking at my own code makes me want to barf
>>51302518
your last else if should just be else, as if the program flow gets to the last else if, it will _always_ be true.
>>51302072
do your own damn employment research faggot
>>51302065
C# but should be easy enough to rewrite it in VB.Netusing System;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Drawing;
namespace GoogleImages
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void searchButton_Click(object sender, EventArgs e)
{
WebClient wClient = new WebClient();
string url = "https://www.google.com/search?tbm=isch&q=" + queryTextBox.Text;
wClient.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64;) Gecko/20100101 Firefox/20.0");
string pageSource = wClient.DownloadString(new Uri(url));
string firstImage = pageSource
.Split(new string[] { "/imgres?imgurl=" }, StringSplitOptions.None)[1]
.Split(new char[] { '"', '&' })[0];
imageUrlTextBox.Text = firstImage;
var imageData = wClient.DownloadData(firstImage);
var imageStream = new MemoryStream(imageData);
imageBox.Image = (Bitmap)Image.FromStream(imageStream);
}
}
}
>>51298891
Currently in the planning phase (10th week,getting very close to prototyping) a semi-p2p file sharing social networking esque platform. I'm very excited to begin. Other than that pushing tests. Woo
>>51302565
>10th week of 'planning'
>no implementation at all
doomed to fail
>>51302343
Make api calls to it :^)
>>51302258
The setters and getters could be worked around for via using the abc collect I linked to.
When you say classes like in sqlalchemy, do you mean you're trying the mimic declarative?
Are you sure it wouldn't be better just to follow my original advice on how to structure it? Do you have a response to that?
Regarding order, there is an OrderedDict class,
but also, I think it may be beneficial to just rely on keyword arguments and etc. first. It may be overengineering to try to do meta classes at this point.
when sqlalchemy was being developed, they figured out the data they were dealing with and the imperative kinks first, developing the sqlalchemy core. only after did they have enough confidence in the domain to understand the need of constructing things declaratively
unless the goal of the project is to learn more about metaclasses, if you want to create something useful and leave open the option to add metaclasses correctly, i'd figure out how to get the simple things organized with a normal class/subclass hierarchy - then make factories/classmethods.
after you're solid on that, see how much taking the sqlalchemy declarative-like route makes sense.
anyone with template experience know what's wrong here?using wide_reference = std::tuple<std::vector<Ts>::reference...>;doric.cpp:9:66: error: type/value mismatch at argument 1 in template parameter list for ‘template<class ...> class std::tuple’
using wide_reference = std::tuple<std::vector<Ts>::reference...>;
^
doric.cpp:9:66: error: expected a type, got ‘std::vector<Ts, std::allocator<Ts> >::reference ...’
i'm confused because std::vector<Ts>::reference looks like a type to me?
>>51302576
>implying there is no implementation
K babe. Go back to the car.
>>51302539
thanks.
>>51302471
you need a map from texture ID to texture. texture ID could be a string, or it could be some kind of enumeration. then you use the IDs in your code
there's various details you might want such a map to have, such as out-of-memory caching, but that's the basic idea
It's time for some maymays.
>>51302660
1/10 at most.
>>51302634
I see. Thanks broski.
>>51302679
I didn't make it, fucklord
>>51302576
Planning and analysis is fundamental to every project. It's always crucial to get this correct otherwise the code that comes afterward can be rendered meaningless when you find that the foundations need to be changed.
>>51302660
objective-c sucks
im retard
>>51302606
fixed itstd::tuple<typename std::vector<Ts>::reference...>
it's possible i may be the devil
c average high school graduate learning python in codeacademy. its boring as fuck, what are some hands on resources i can use to learn python??. i know nothing about technology but would like to code of those nifty browser games some day.
>>51302765
>programming because wants to code gamez
you are the cancer
>>51302769
What are those values? Time?
>>51302789
i honestly just want to be fluent in python more than anything. plz help. i constantly feel like a retarded babby lurking this board. are there any crash courses for tech noobs that you guys would recommend for cancer to become... not cancer?
just got leenux installed on my phone, gonna play around with it
>>51302792
Arbitrary values of a closed source benchmark.
>>51302807
just find something to work on and start working on it
search for the stuff you don't know how to do, there's a shitton of resources espically for something like python
you need to actually do some programming to get good at it
>>51302813
Suggestion: Run SSH on your phone. SSH from a laptop or desktop into your phone and take advantage of the full keyboard. Then write some ARM assembly programs and fuck around.
>>51302813
Did you have any weird hurdles you had to jump through? I have an old Galaxy S3 I want to try this on.
>>51298946
Like ATM machine
what's the point of wrapping an enum in a struct
>>51303103
there are apps that will install linux in your phone for you
you could also do it manually and learn a thing or two
google it
why the fuck does coursera has this stupid "enroll" periods or something i just wanna check out the stupid videos whenever i want not to follow with a class of faggots wtf
anyway, can anyone recommend a good mooc on information theory?
>>51302425
your pic isn't from the official spec, is it?
>float
>Real floating-point type, usually referred to as a single-precision floating-point type. Actual properties unspecified (except minimum limits), however on most systems this is the IEEE 754 single-precision binary floating-point format. This format is required by the optional Annex F "IEC 60559 floating-point arithmetic".
>double
>Real floating-point type, usually referred to as a double-precision floating-point type. Actual properties unspecified (except minimum limits), however on most systems this is the IEEE 754 double-precision binary floating-point format. This format is required by the optional Annex F "IEC 60559 floating-point arithmetic".
https://en.wikipedia.org/wiki/C_data_types
>>51303191
which ones did you use? I mean I guess I could google it but I am curious.
I had today off for veterans day so i wrote a small program to pull all the full sized images off jb gallery and stitch them together, since they store them in slices to prevent people doing exactly what I'm doing.
Now I just browse by pulling images directly and can choose to save them to disk or not. It's nice.
>>51302529
maybe you should divide things more into different classes and packages so that you don't need to OverlySpecifyWhatEverythingIsUsedFor
>>51303303
pedo.
>>51302707
this
but you don't need to plan every detail in advance if you do OOP
>>51303314
fite me
Can someone explain this line in C:
x = x ? x : !x;
My understanding (let x = 3 in the example):
1. set x = x (in this case 3 = 3).
2. the return value of the "=" operator in C is a rvalue which in this case is "3"
3. 3 by itself evaluates to true, correct? go with x instead of !x;
4. now it's just the statement "x" which is a no operation, same if it evaluated !x. Similar to saying x+3; this line does nothing if we're not using it.
x = (x==x) ? x : !x; This makes sense to me, but simply x = x ? x : !x; does not.
>>51303408
From what I can tell, if x is equal to x, return x. Otherwise, return not x.
Doesn't make any sense to me, really.
>>51303408
Essentially it's doing:if (x==0)
x=1;
>>51303408
If x is not zero set x to x else set x to !x (which I believe is implementation defined - but most likely 1?)
I think the intent would be more clear like this:if (x == 0) x = !x;
>>51303408
a ? b : c is a ternary operator
if a is true, the result of the expression is b
if a is false, then c.
so:
x = x ? x : !x means:
if x is true (i.e. not 0), then set x to x (i.e. no change)
if x is false, set x to !x, or true
this anon is correct >>51303458
>>51303408
no. google "C ternary operator"
>>51303300
I didn't post that pic
seriously, using google can't be that difficult...
>>51303408
What is the type of x?
This is a ternary operator.
(x==x) is always true.
x ? x : !x
means that if x is not NULL pointer or false, then it's the opposite of !x.
Note I can't be more specific without the type of x
>>51303408
if x evaluates to true it stays the same, if not it's negated
assuming x is an integer it will do nothing unless x is 0, in that case it'll return 1
>>51301784
what is this:
https://en.wikipedia.org/wiki/C11_(C_standard_revision)
Type-generic expressions using the _Generic keyword. For example, the following macro cbrt(x) translates to cbrtl(x), cbrt(x) or cbrtf(x) depending on the type of x:
#define cbrt(x) _Generic((x), long double: cbrtl, \
default: cbrt, \
float: cbrtf)(x)
>>51303471
>(x==x) is always true.
no it's not?
you're 100% dumb if you think that.
>>51303408
>x = (x==x) ? x : !x; This makes sense to me, but simply x = x ? x : !x; does not.if(x) {
x = x;
}
else {
x = !x;
}
it's an implicit conversion to bool, like(bool) x
>>51303482
when is it not true?
>>51303493
>it's an implicit conversion to bool, like(bool) x
or like(x != 0)
>>51303481
I didn't know about that. That looks nice.
>>51303503float x = NaN;
if (x == x) {
// this will never occur.
}
>>51303482
>implying that a variable and the exact same variable is different at the same time
>>51303530
oops, in C NaN is defined as NAN.
>>51303541
>
see >>51303530
it's amazing people don't know the properties of IEEE 754.
>>51303408
Hey I posted this, thanks for the replies I think I get it now.
I was understanding it as this:
(x = x) ? x : !x;
when it's actually more like this:
x = (x) ? x : !x;
eg x = if(x) ? x : !x;
Is the if implicit? I wasn't aware of implicit ifs.
or am I still wrong?
>>51303570
in simple terms, when you see something like this:a = b ? c : d;
this actually means:if (b) {
a = c;
} else {
a = d;
}
remember that.
>>51303570
please specify the type that x is
>>51303598
it's type of int (also remember this is C not C++)
>>51303597
Alright I'll just remember this, thank you
>>51303562
i knew it, i just didn't have it in mind (but i didn't say it was impossible, i just asked for an exampleas in >>51303503) because i'm not quite autistic enough to really give a shit about things that are completely irrelevant to me. i don't have a use for comparing NaN
>>51303623
>im a retard
>fuck off retard
>i was only pretending
>>51303620b ? c : d
can also be used on its own without assignment likenigger(b ? c : d);
>>51303649
you baka senpai
Can someone help me convert this inline Python code to perl? I'm retarded and just don't get perl. You can make it as terse as you want, -ne encouraged.#!/bin/sh
default_network="192.168.2.0/24"
if [ $# -eq 1 ]; then
network="$1"
else
network="$default_network"
fi
nmap -sn "$network" | python -c '
import re
import sys
for line in sys.stdin:
m = re.search("Nmap scan report for ([\d\./]+)", line)
if m:
print(m.group(1))
'
>>51303684
>from one crappy language to another
>fi
>>51303684while (<STDIN>)
{
if (/Nmap scan report for ([\d\.\/]+)/)
{
print STDOUT "$1\n";
}
}
I have a question about _Generic
Here is my signature:void renderThisTexture(SDL_Texture* texture, int x, int y, int w, int h);
I want to make a _Generic to allow w and h to be NULL, and use a different function.
how could i make _Generic check for the types of w and h, to see if they are both NULL or int?
>>51302065
You should use Google APIs instead of going about it from scratch.
>+300
We need a new thread now !
>>51303765
That's a really bad idea, NULL is allowed to be either 0 or (void *)0, meaning if you were to dispatch on int vs void *, you could have different behavior depending on how NULL was defined.
Trying to optimize some code for the AVR, specifically ISR overhead. I want to have my code be able to modify an interrupt handler while running, so I have all the interrupt handlers in a function pointer table in memory. The baked-in handlers just index this table and call the function in the table when an interrupt is received.
However, the issue is because I have a compile-time indeterminate function call in the ISR the compiler can't optimize away some of the register stacking necessary because it's in an ISR. So it stacks all temp registers (16 of them), which in AVR is 64 cycles of overhead on top of calling and returning from the interrupt.
Most of the interrupt routines for any interrupt use less than four registers at a time (most are two) and I want to make it so that any function that is used in the interrupt table respects ALL the registers it uses so that the generic interrupt handler only has to push two registers (for the function table call). Is there an attribute or something in gcc that allows one to mark a function to respect all registers and disrespect all registers?
tl;dr are there function attributes in gcc that make the compiler respect or disrespect registers during allocation?
>>51303684nmap -sn "$network" | perl -ne '/Nmap scan report for (.*)/ and print "$1\n"'
# or just
nmap -sn "$network" | awk '/Nmap scan report/ { print $5 }'
Dear anons,
Hello from Krasnogorsk.
I'm a compiler maintainer. I have in-depth knowledge of the C grammar and its practical uses.
If you have any question about C syntax and semantic, please ask
>>51303408
Identifiers, the assignment operator (=), and the ternary conditional operator (? and :) are all right-associative, and I've listed them in ascending order of precedence.
What this means is that your tree looks like this. I'm using brackets to isolate each component as the compiler breaks it down.
((X) (=) ((X) (?) (X) (:) (!X))
So we have the Assignment operator which associates to X on its LHS and X ? X : !X on its RHS. And the ternary operator associates to X on its CondExpr, X on its TrueExpr, and !X on its FalseExpr.
What your fragment does is this:
X =
Assign to the value X...
X ?
... If X is true (i.e. not 0) ...
? X
...then the value to assign to X is X...
: !x;
...otherwise, assign it Not-X (which will be 1, since X is 0 in this case)
>>51302660
The shirtless man tells us a lot about the nature of Objective-C programmers.
Thanks,
Anon
just found out that https://www.safaribooksonline.com has 32,412 technical books and 3,257 videos free for 30 days
should I download the entire site and upload it somewhere
>tfw community college
>closest Uni to take my credits is an hour away
Should I just stop at Associate's? Is there even a need for a Bachelor's in CS for s programming job?
is there a scripting language with static typing
i hate python
>>51304131
yes lmao
>>51304131
Sure
>>51304150
haskell
>>51304146
without education, you have no credentials
without credentials, you won't get an interview
without an interview, you won't get a job
without a job, your only alternative is to be a NEET, and live a lonely, unfulfilled life.
>>51304188
So an Associate's is equivalent to no education?
>>51304209
no idea what that is, sorry
CS degree would always look good on a resume
>>51303530
ILL FUK U N UR NAN UP, ILL REK YA WHOLE FAMILY U WATCH YA FUKEN WANKER
new thread people
>>51304261
>>51304261
>>51304261
Anybody have any experience in F#? I'm trying to get a sequence of floats from a bunch of strings, but instead I get a list full of: "{Microsoft.FSharp.Collections.SeqModule.revamp@914<double,double>}"
The code that generated the above is:
let getFloat =
str.Split ([|'\n'|])
|> Seq.map(fun line -> line.Split([|','|]))
|> Seq.map(fun values -> float values.[0])
The input string is something like "String, String, Int, String, Float", and I need the floats.
>>51304188
if you've got the sufficient drive to succeed you can skip a college education, like Jacmob who made the first working RuneScape bot after a major anti-bot update and showed it to the CEO of Jagex, who hired him instantly
>>51304280
life is not like that anon
you need to understand that you are not special
you will not get opportunities like this.
>>51304131
talk to the owner of http://it-ebooks.info/
I bet he posts in /g/
>>51304112
Any cool C syntax tricks most people don't know about?
>>51300078
>JavaScript
has vm/jit
>Python
has vm/jit
>C#
>F#
.net vm
>PHP
>Ruby
have vm/jit
>SQL
????
>>51304954
Hello anon,
The comma expression is very uncommon and little-known, but can be useful.
You can do this, to example:
int x = someFunction(1, 2, (x = anotherFunction()++, x %= 2, doAnotherThingWith(x)));
The comma expression takes the form:
comma-expression
: comma-expression ',' assignment-expression
;
Note that assignment-expression also has a ternary-conditional-expression production, which has itself a boolean-or-expression production, and so on, this is how C implements operator precedence without needing support in the parser for declaring precedence in advance. Anyway, usually it is folded into a generic 'expression' rule, but it's an official part of the C standard so it is supported on any C compiler.
I last used it to implement a macro that would take an argument and call multiple functions passing it that argument. I could not do this by using a function call statement, as that would prevent e.g. using it in an assignment. But I could successfully do it like this:
#define registrate(X) (register_it_here(X), register_it_there(X), X)
which would, if used in this case:
some_function(registrate(x));
in place of
some_function(x);
still have the desired result (of both calling the functions and giving some_function x as an argument.
Hope this is interesting and useful.
Thanks,
Anon
>>51305484
cool