473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Set, Mark, and Apply Decoration

Set, Mark, and Apply Decoration

Provide a means to set the decoration that will be applied to all
marked functions (and maybe classes) within a scope (module, class,
or function).

For example purposes, I will use a decor object that would presumably
be made available in each scope (via locals, perhaps). I'll say that
it has (atleast[*]) a method set() with the following signature:

def set(self, *decorators, **attributes):
...

This method could be used to set/reset the decor, 0 to n times, within a
given scope. The decor of one scope would only be applicable within itself
and, perhaps, within its nested scopes. In this way, you could define a
region(s) wherein the same decoration(s) could be applied to marked
functions - there would be no need to repeat the decoration declarations
for functions that share the same decor.

The functions to be decorated (using the current decor) would be marked.
This demarcation could be done by a symbol or by a keyword. E.g.,

'<MARK> def foo():' OR 'def <MARK> foo():' OR 'def foo() <MARK>:'
Where <MARK> can be replaced by whatever is deemed the least objectionable
symbol or keyword. For example purposes, I'll use 'def *foo():'.

I'll give an example, now, showing this proposal side by side with the
current decoration scheme:

# current scheme # proposed scheme
class A(object): class A(object):
# static methods # static methods
@staticmethod decor.set(staticmethod)
def f(): def *f():
pass pass
@staticmethod def *g():
def g(): pass
pass ...
... ...
# undecorated # undecorated
def h(): def h():
pass pass

# class methods # class methods
@classmethod decor.set(classmethod)
def i(): def *i():
pass pass
@classmethod def *j():
def j(): pass
pass ...
... ...
# garish # garish
D = compose(A,B,C, decor.set(A,B,C,
funcattrs(d='d', d='d',e='e',f='f'
e='e',f='f')) def *k():
@D pass
def k(): def *l():
pass pass
@D ...
def l(): ...
pass ...
NOTE: That garish one is *much* worse if you don't use function composition.
[*]
You might want a way to clear the decor, or a way to add or remove
decorations without resetting the entire decor, or a way to ask what
the current decor is, if any.

Jul 18 '05 #1
0 1167

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Andrew Tang | last post by:
Hi, I need some help with understanding this piece of css. <u>This is a <a href="#" style="text-decoration:none;">hyperlink</a> with surrounding underlining</u> From what I understand of css,...
3
by: Christian Roth | last post by:
What I want: <p style="text-decoration: line-through"> Stricken <span style="text-decoration: none">not stricken</span> </p> , where "Stricken " should be the only thing that is lined...
6
by: Big Bill | last post by:
Doesn't seem to work as I still get an underline. Is there a reason for this? Is this normal? You can see examples on my site. BB -- www.kruse.co.uk/ seo@kruse.demon.co.uk seo that watches...
8
by: Bern | last post by:
hi all, what is the rule for decorating a symbol in c++?
2
by: mike | last post by:
I am looking for the javascript equivalent of: style="text-decoration:underline;" in a span tag created dynamically. I was thinking it was: mySPAN.style.text-decoration="underline"; but...
2
by: chandy | last post by:
Hi, I am trying to access the text-decoration property for an element's style. I know that this works: Object.style.color = 'blue'; but this doesn't:
2
by: Francesco Moi | last post by:
Hi. I want to create a link within a H1 text: --- <h1><a href=foo>text</a></h1> --- And I've got (in my CSS) --- h1
2
by: GloStix | last post by:
For some reason, FF likes to put a black underline on all my buttons. No matter what I do, it has the line I've tried displaying as block and cursor, anything.. Also I've been trying to get it so...
1
by: webster5u | last post by:
Hi, i need apply two different hyperlink:hover style cause by different background color. what i do is, i put css external link as a:hover.paging { color: #cc0000; text-decoration: none;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.