# Attributes support proposal

- Thread: https://externals.io/message/16074
- Original archive: https://news-web.php.net/php.internals/16074
- Started by Duncan McIntyre on 2005-04-25T12:30:27+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #16074 — Duncan McIntyre — 2005-04-25T12:30:27+00:00

URL: https://externals.io/message/16074#16074

Sebastian - how's the parser going?

I've finished my patches to make attributes work as native PHP tokens.

You can get the code and read a discussion about the various possibilities for 
implementation at

http://www.calligram.co.uk/oss/Attributes

I really hope we can come to a consensus on how to suppor this in PHP.

Duncan

---

## #16076 — Hendy Irawan — 2005-04-25T15:06:01+00:00

URL: https://externals.io/message/16074#16076 · In reply to: #16074

> http://www.calligram.co.uk/oss/Attributes

Whew Duncan! That's *VERY* nice.

Anyways... Annotations (structured comments) vs. Attributes?

Here's my take:

Since annotations are comments, you can remove them without modifying
behavior. However, attributes are actually *needed* since they are
part of the code. If you remove the attributes, you're changing
behavior.

phpDoc comments are... comments! You can remove all comments in your
code and your script will run just as well when they did have
comments.

So, IMHO, attributes != annotations. They're two different beasts, for
different purposes.

-- 
Hendy Irawan
http://www.gauldong.net
http://dev.gauldong.net

---

## #16079 — Christian Schneider — 2005-04-25T16:28:59+00:00

URL: https://externals.io/message/16074#16079 · In reply to: #16074

Duncan McIntyre wrote:
> http://www.calligram.co.uk/oss/Attributes

In your example I fail to see how
     	@[ WidgetType("Select"); 
AllowableValues(array("Current","Savings")); ]
is different from the good old
	var $WidgetType = "Select", $AllowableValues = array("Current", "Saving");
apart from looking weird and scary (-:C

Just my $.02,
- Chris

---

## #16080 — Duncan McIntyre — 2005-04-25T16:48:32+00:00

URL: https://externals.io/message/16074#16080 · In reply to: #16079

It's different because in your example there is no way of knowing that 
$AllowableValues refers to $WidgetType. 

You would have to explicitly code that relationship into every class which 
needed to know it.




> Duncan McIntyre wrote:
> > […]
>
> In your example I fail to see how
>      	@[ WidgetType("Select");
> AllowableValues(array("Current","Savings")); ]
> is different from the good old
> 	var $WidgetType = "Select", $AllowableValues = array("Current", "Saving");
> apart from looking weird and scary (-:C
>
> Just my $.02,
> - Chris

Duncan

---

## #16081 — Christian Schneider — 2005-04-25T17:12:55+00:00

URL: https://externals.io/message/16074#16081 · In reply to: #16080

Duncan McIntyre wrote:
> It's different because in your example there is no way of knowing that 
> $AllowableValues refers to $WidgetType. 

My solution would be
	var $attributes = array(
		'accountType' => array(
			'Type' => "Select",
			'AllowableValues' => array("Current","Savings")
		)
	);
with a central attribute definition or alternatively
	var $attributes_accountType = array(
		'Type' => "Select",
		'AllowableValues' => array("Current","Savings")
	);

But then again I think the whole thing is typical OO bloat anyway and 
that's why I don't want to have language features added for it (-:C

Over and out,
- Chris

---

## #16084 — Sebastian Bergmann — 2005-04-26T06:27:23+00:00

URL: https://externals.io/message/16074#16084 · In reply to: #16074

Duncan McIntyre wrote:
> Sebastian - how's the parser going?

 Have a look at

   http://pear.php.net/pepr/pepr-proposal-show.php?id=237

-- 
Sebastian Bergmann                      http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69
